Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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?

Replies are listed 'Best First'.
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.


      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 Anonymous Monk on Nov 09, 2009 at 01:27 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
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 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?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2021-10-27 09:20 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (91 votes). Check out past polls.