Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
XP is just a number
 
PerlMonks  

Using exit

by Anonymous Monk
on Dec 30, 2004 at 16:30 UTC ( #418297=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,
Anyone knows how to use "exit" in the code and than restart again after few seconds, like:

perl code here...
#stop for 3 seconds using exit;
exit;
#now, restart the rest of the code
rest of the perl code here...

Any one? Thank you!

Comment on Using exit
Re: Using exit
by dragonchild (Archbishop) on Dec 30, 2004 at 16:32 UTC
    You probably want to look at sleep, not exit.

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Using exit
by The Mad Hatter (Priest) on Dec 30, 2004 at 16:32 UTC
    I think your best bet is to sleep the process rather than terminating it.
Re: Using exit
by steves (Curate) on Dec 30, 2004 at 16:34 UTC

    exit will cause the process to stop running. To restart it and pick up at another location, you'd have to save some sort of data before exiting that would tell you where to pick up, then load and use that data to conditionally execute code on restart. This doesn't sound like a good design to me. Are you sure you don't want to just sleep for 3 seconds, then continue on?

      Tried but it doesn't work the way I want cause when I use sleep(3); it doesn't display what I already have processed on the browser it just seats there and of course "sleep" for 3 seconds. and using exit displays everything at that point to the browser, I just need some similar trick to display whatever at some point in my program and than move on.
        if you're trying to get things to display to the browser, there are other things to do:
        $|++;
        to force writes to be "immediate". (i'm forgetting the proper term .. not enough coffee yet this morning ... )

        the reason  exit is sending the output to the browser is because the write buffer is closed, like a  close on a filehandle.

        It sounds like you are developing a CGI application. If this is the case, turning off output buffering may ensure that the output from the script is displayed in the browser:
        $|++;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2014-04-18 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (471 votes), past polls