Pascal666 has asked for the wisdom of the Perl Monks concerning the following question:

Using file named sleep.pl containing only "sleep 10;", when I run "wperl sleep.pl" from the command line I get another prompt immediately (as expected). When the same command is run from a cmd file however, the cmd file waits for 10 seconds for wperl to finish before continuing. How do I get wperl in a cmd to return immediately? I am using ActivePerl-5.10.0.1005-MSWin32-x64-290470 on Vista sp2 x64.
  • Comment on wperl in cmd file not returning immediately

Replies are listed 'Best First'.
Re: wperl in cmd file not returning immediately
by ikegami (Patriarch) on Aug 31, 2009 at 19:21 UTC

    Batch files wait for GUI applications to terminate. The interactive shell does not. Replace

    wperl -e"sleep 10"
    with
    start wperl -e"sleep 10"

    To get the interactive behaviour in a batch file.

      Works perfectly now. Thank you.
Re: wperl in cmd file not returning immediately
by Anonymous Monk on Aug 28, 2009 at 08:16 UTC

      Is there a particular section of that man page you thought was relevant?

      wperl runs in the background just fine when executed from a command prompt. Completely rewriting a script to use Proc::Background should not be necessary.