in reply to launching perl processes from a perl script on Win2K

If you want to start a whole bunch of programs and you are not bothered about their return values then you need to start each command in a 'new window'. In UNIX you would add an ampersand to the comand. The windows approach would be to use the start command.

The following example shows this in action. The main script starts a number of other scripts which run simultaneously. The command also uses wperl.exe which is perl without a command window.

#! /usr/bin/perl -w use strict; use warnings; foreach (1..5) { system (qq(start wperl.exe -e "sleep($_);print 'Done!'")); } print "Launching application has finished\n";

Replies are listed 'Best First'.
Re^2: launching perl processes from a perl script on Win2K
by dwhite20899 (Friar) on Oct 14, 2004 at 14:43 UTC
    I do something like this to fork off another process on Win32.
    use Win32::Process; $bInherit = 0; $Dir = "c:\\"; $Flag = CREATE_SUSPENDED | CREATE_NEW_CONSOLE | HIGH_PRIORITY_CLASS ; if (Win32::Process::Create( $Process, $App, $Cmd, $bInherit, $Flag, $Dir ) ) { $Pid = $Process->GetProcessID(); print "\n\tnew process created with PID $Pid"; while (1 < $Process->Resume() ) { } $Result = $Process->Wait($Timeout * 1000); if (! $Result) { print "$tmp did not end in $Timeout sec, killed"; $Process->Kill(0); } else { # process ran ok, give message } } else { print "\nunable to create the new process.\n"; $tmp = Win32::FormatMessage(Win32::GetLastError() ) ; print "\n $0 Error: $tmp\n"; }