in reply to Restart Long Running Perl Script

When you "exec" something, it will replace the current running script, with the new one. So you could try something like
sub restart{ exec $0; }
but doing that is usually a sign of a bad program design. What is the reason you need to restart? Can't you just reset the variables in the original script, and let it keep running?

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: Restart Long Running Perl Script
by avo (Pilgrim) on Feb 13, 2006 at 13:18 UTC
    I have to restart, as the FTP server could provide completely different script than the one currently running. Will exec $0 work on Win32 ?
      Will exec $0 work on Win32 ?

      Yes.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
      I don't know much about windows, but if it dosn't work, you could try
      sub restart{ system(1, $0); # windows trick to launch a new process exit; # will need to exit original script }
      but maybe the windows experts will know something better.

      I'm not really a human, but I play one on earth. flash japh