Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Event Driven - timer

by ig (Vicar)
on Dec 15, 2008 at 15:10 UTC ( [id://730423]=note: print w/replies, xml ) Need Help??


in reply to Event Driven - timer

You could use alarm and a signal handler.

#!/usr/bin/perl # use strict; use warnings; use Data::Dumper; $SIG{ALRM} = sub { print "printing from within sub routine\n"; alarm(1); }; alarm(1); while(1) { print "main loop proceeding\n"; sleep(1); }

produces:

main loop proceeding printing from within sub routine main loop proceeding printing from within sub routine main loop proceeding printing from within sub routine main loop proceeding printing from within sub routine main loop proceeding printing from within sub routine main loop proceeding

Note: you don't need the sleep in the main loop. You will, no doubt, have better things to do.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://730423]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-24 02:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found