Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

timer without modules

by elunatic (Initiate)
on Nov 09, 2009 at 00:48 UTC ( #805829=perlquestion: print w/ replies, xml ) Need Help??
elunatic has asked for the wisdom of the Perl Monks concerning the following question:

im reasonably new to perl and i need to create a timer to delay use of a publicly messaged command... problem is the shell i plan to run this script on doesnt have any of the good 3rd party modules so im stuck trying to make a timer on my own and have no clue how.... help plz?

Comment on timer without modules
Re: timer without modules
by McDarren (Abbot) on Nov 09, 2009 at 00:57 UTC
    How about the built-in sleep function?

    If that isn't suitable, then you'll probably need to provide a little more detail about what you are wanting to do.

    Cheers,
    Darren

      what im trying to do is create a weather script for an irc bot i made with IO::socket, but before i use the weather script on it i need to ensure users cannot flood the bot or channel using the publicly msg'd command.
Re: timer without modules
by biohisham (Priest) on Nov 09, 2009 at 01:02 UTC
    what do you mean by "delay use"? Do you probably mean sleep? this function can cause the script to pause for the amount of seconds specified or forever if no seconds were specified. Consider this very simple example:
    for($num=5;$num>0;$num--){ print "$num\n"; sleep 2; }
    It'd take a while after printing the current value of $num and looping once again as affected by the duration of time provided in the EXPR to sleep. Best of luck...

    Excellence is an Endeavor of Persistence. Chance Favors a Prepared Mind.
Re: timer without modules
by Anonymous Monk on Nov 09, 2009 at 01:27 UTC
      right, but i do not have root access on the box in question, which makes it sort of a pain with certain modules... unless you can point me in the right direction to do it without root **as i said im pretty new to this** much thanks guys.
Re: timer without modules
by doug (Pilgrim) on Nov 09, 2009 at 17:41 UTC

    What do you need that alarm() doesn't provide?

      doesnt alarm pretty much halt the script like sleep does?
      if not would you mind giving me an example of how i could use it?

      thanks for all this help and info guys, its really appriciated :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://805829]
Approved by biohisham
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-08-02 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (55 votes), past polls