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


I need some help. I need to check if a process is running and then continue on with some Perl code after the process completes. (I am going to use notepad.exe as an example app)

The Perl call prglst doesn't work for me so I wrote some DOS code that works sending the data through to a file that I can read:

set tempfile = "C:\Testing\TestNotepadRunning.txt"
tasklist > %tempfile%

Then transposing that call into Perl won't work for me:

my @tempfile = 'C:\Testing\TestNotepadRunning.txt'; system('TASKLIST > $tempfile');

Can you help?

Replies are listed 'Best First'.
Re: Find Running Process
by DrHyde (Prior) on Apr 10, 2012 at 09:55 UTC

    I could write your code for you, but that won't help you much. Instead I recommend that you go and read the Llama book. You need to learn about interpolation and what the @ and $ sigils mean.

    I'm also not sure what this 'prglst' that you speak of is. It's not part of perl.

Re: Find Running Process
by repellent (Priest) on Apr 10, 2012 at 07:16 UTC
    useautodie qw(:all);
    # single quotes here to keep the backslashes as-is my $tempfile = 'C:\Testing\TestNotepadRunning.txt'; # double quotes here to interpolate $tempfile system("TASKLIST > $tempfile");
Re: Find Running Process
by Anonymous Monk on Apr 10, 2012 at 07:06 UTC

    use double quotes because single quotes do not interpolate while double quotes do interpolate. perlintro and Modern Perl explain interplation.