0

I'm using ActivePerl on a Win 7 box and I want to use the Proc::Reliable CPAN module. It downloaded and installed properly but when I tried to run the following code, it failed at run

my $newProc = Proc::Reliable->new()
$newProc->run("perl.exe -e print 'hello world'");

I tried a couple things, such as testing the status and trying to retrieve output, but with no luck. As best as I can tell, the program dies silently on run.

For reference perl.exe is in my PATH variable and I'm calling this from commandline as: perl.exe test.pl

tzenes
  • 1,699
  • 2
  • 15
  • 31

3 Answers3

4

It probably isn't failing. -e print 'hello world' tells perl to execute the code print with @ARGV set to hello world (or perhaps ("'hello","world'"), I forgot how windows cmd quoting handles ''). This prints the contents of $_ (that is, undef) to STDOUT.

Always use warnings. Even on one-liners. Perhaps especially on one-liners. Compare:

$ perl -e print 'hello world'
$

and

$ perl -we print 'hello world'
Use of uninitialized value $_ in print at -e line 1.
$
ysth
  • 96,171
  • 6
  • 121
  • 214
  • If I believed my program was failing for other reasons, what would be the correct way to test it? I used -e print, because it was quick, is there any other way? – tzenes Sep 07 '10 at 18:11
  • @tzenes: sorry, I don't actually know anything about Proc::Reliable. It seems like it should provide some well documented way to test, though. Change the inner program to create a file or output a debugging statement to see if it's starting at all? – ysth Sep 07 '10 at 20:14
3

Quoting is a little different in the Windows "shell". To get your mini-program to be interpreted as a single argument, try something like

perl.exe -e "print qq/hello world/"
mob
  • 117,087
  • 18
  • 149
  • 283
  • While that does work for windows "shell" it won't display any output in my example as the stdout isn't redirect to the "shell" (or anywhere else). – tzenes Sep 07 '10 at 21:30
  • @tzenes: What if you say `($stdout) = $newProc->run('perl.exe -e ...'); print $stdout` ? It looks like the output of the process should be captured by the `Proc::Reliable` module and returned. – mob Sep 07 '10 at 21:41
  • I get no output or the print $stdout fails. Upon further investigation, any `print` after a `run` fails. – tzenes Sep 07 '10 at 22:25
2

I have contacted the author of the Proc::Reliable module and he confirmed that the module does not work on Windows.

Vess
  • 117
  • 3
  • 7