Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: PERL on VMS

by fisher (Priest)
on Jan 30, 2012 at 10:02 UTC ( #950730=note: print w/ replies, xml ) Need Help??


in reply to PERL on VMS

locks up until the perl program exits ... I just wrote a new perl program

Just a five cents - maybe I misundertood you, but if you want to prevent your program from hanging up in loop forever, you can use timer as a watchdog inside your perl program. The hanlder should exit if some global variable doesn't change, and when everything is going rigth, you explicitly change it in main program loop. This is just an example usage for the idea.

#!/usr/bin/env perl use strict; use warnings; our $flag = 0; $SIG{ALRM} = \&Watchdog; sub Watchdog { print "--- Tick ".$main::flag++."---\n"; if ($main::flag >3) { print "--- Bark! Bark! ---\n"; exit 1; } alarm 1; } alarm 1; while(1) { print "main loop...\n"; while(1){}; print "done\n"; $main::flag = 0; }


Comment on Re: PERL on VMS
Download Code
Re^2: PERL on VMS
by choroba (Abbot) on Jan 30, 2012 at 10:09 UTC
    The "done\n" part is not executed (because of exit). You cannot use last instead of exit, either.
      Yes, I know. This is a demo how watchdog reacts to an infinite loop.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-10-02 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (56 votes), past polls