User Control Panel
Advertisements

HELP US, HELP YOU!

while(1) in a pl?

 
Post new topic   Reply to topic    Bot Depot Forum Index -> Ideas
View unanswered posts
Author Message
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sat Feb 19, 2005 10:05 am    Post subject: Reply with quote

My bot seems to be collecting things in the while(1) loop, to neaten this up i would like to put the contents in an external .pl file. Would access to this be to slow? If so would storing it in a hash be faster?
Back to top
mat007
Almost An Agent
Almost An Agent


Joined: 12 Jan 2004
Posts: 1375

Reputation: 15.8Reputation: 15.8
votes: 2

PostPosted: Sat Feb 19, 2005 10:44 am    Post subject: Reply with quote

Well an easy way would put this in the external file:

Code:
sub do_loop<br />{<br /> my $msn = shift;<br /> $msn->do_one_loop();<br />}<br />1;


in your bot file put:

Code:
require("some external file.pl");<br />&do_loop($msn);<br />


If your like adding a 1 to a variable to every loop it probably would slow it down a bit as a loop isnt like a second etc.
Back to top
eric256
The Keymaker
The Keymaker


Joined: 03 May 2006
Posts: 2292
Location: Colorado
Reputation: 47Reputation: 47Reputation: 47Reputation: 47Reputation: 47

PostPosted: Sat Feb 19, 2005 5:01 pm    Post subject: Reply with quote

QUOTE(draget @ Feb 19 2005, 02:05 AM)
My bot seems to be collecting things in the while(1) loop, to neaten this up i would like to put the contents in an external .pl file. Would access to this be to slow? If so would storing it in a hash be faster?

Doing lots of stuff in the loop will eventualy slow it down. Storing the code for the loop in a seperate file will have no effect if done right. You could put the entire loop in an external file and just require it at the same spot you wold put the loop code. Or you could do like matt said and do
Code:
<br />while(1) {<br />    &do_loop($msn);<br />}<br />

_________________
Eric256
Proud previous owner and current admin of Bot-depot.com
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Feb 20, 2005 5:27 am    Post subject: Reply with quote

Thanks guys, I know the bot will eventualy slow down, this is my first bot, not too efficient, but still seems fairly quick, next one will be better.....but thats a long way off!


Oh btw

Quote:
sub do_loop
{
my $msn = shift;
$msn->do_one_loop();
}
1;
What s the little '1;' at the end for?
Back to top
mat007
Almost An Agent
Almost An Agent


Joined: 12 Jan 2004
Posts: 1375

Reputation: 15.8Reputation: 15.8
votes: 2

PostPosted: Sun Feb 20, 2005 10:54 am    Post subject: Reply with quote

Returns a true value.
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Feb 20, 2005 10:58 am    Post subject: Reply with quote

ok,

probably a stupid question but why not just return 1; inside the sub?
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Sun Feb 20, 2005 11:01 am    Post subject: Reply with quote

I think it's so that if you "require" a file, then it will return a true value, such as:

Code:
$reply = require('./file.pl');


$reply will then eq 1 when the file has finished.

_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
draget
Not Yet a God
Not Yet a God


Joined: 29 Dec 2004
Posts: 367
Location: Australia
Reputation: 32.2Reputation: 32.2Reputation: 32.2

PostPosted: Sun Feb 20, 2005 11:12 am    Post subject: Reply with quote

aaah, thanks!
Back to top
alienz
Almost An Agent
Almost An Agent


Joined: 22 Mar 2004
Posts: 1436
Location: Mars
Reputation: 55.7

PostPosted: Sun Feb 20, 2005 7:39 pm    Post subject: Reply with quote

Can't put the 1; inside the sub anyway.
_________________
Check out Botworld! A dev resource for things bot.
Downloads, articles, news, fourm and more.
http://botworld.marzopolis.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> Ideas All times are GMT
Page 1 of 1

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group