in reply to process management

You need the /\d/ match because the inner my $pid masks the outer, which is the condition for your while loop to go on. Invoking pgrep inside the loop and assigning its output to $pid declared as my inside the loop doesn't change the value while() is looking at (the outer $pid).

Drop the inner my:

my $pid = `pgrep -f _collectDataScript.pl`; if ($pid) { while($pid) { print "Waiting for process $pid"; sleep(10); $pid = `pgrep -f _collectDataScript.pl`; } }

Also note that the backticks yield the output of its command with a newline appended.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}