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

What is wrong with the following code:
use Win32::Process; my $Process; unless (Win32::Process::Create( $Process, "D:\\Profiles\\rkinyon1\\Desktop\\BOOST2\\mm_sim\\bin\\mm_sim.pl", "mm_sim.pl", 0, DETACHED_PROCESS, ".")) { print "The process wasn't created\n"; } else { sleep 10; system "telnet localhost 4455"; }

The pertinent things to note are that the file mm_sim.pl is a PERL script that creates (among other things) a telnet server on localhost:4455. I have done a system() call and it works just fine. (As in, I can telnet to localhost:4455 without a problem from another window.) Does Win32::Process::Create() just not like PERL scripts? That's rather prejudiced...

Replies are listed 'Best First'.
Re: Win32 Processes
by the_slycer (Chaplain) on Mar 31, 2001 at 03:12 UTC
    Per the Cookbook -
    use Win32::Process; Win32::Process::Create($Win32::Process::Create::ProcessObj, 'c:/perl/bin/perl.exe', #path to perl 'perl script.pl', #perl script 0, DETACHED_PROCESS, ".")or die "$!";
    I have used this in the path with no issues - mainly for Tk apps.
Re: Win32 Processes
by jplindstrom (Monsignor) on Mar 31, 2001 at 03:23 UTC
    A guess:

    The POD states that the second arg is:

    $appname -- full path name of executable module

    So you'll need an actual executable program there, e.g. perl.exe, which I guess is found in the $^X variable (the current Perl script is in $0).

    So, why does system() work? Because the system() call is smarter and will try to start the main application if you have the file extension associated with something. And .pl is associated with perl.exe if you use ActivePerl.

    /J