http://qs321.pair.com?node_id=1108298


in reply to Executing perl program from another perl program and capturing the output

Hi there,

You don't want to use 8.3 names. You just need to pass each individual parameter to system as a list, instead of together in a string. That way the parameters are already divided up and not further split on space characters. Unfortunately system does not capture its output, but Capture::Tiny is to the rescue in that regard:

use Capture::Tiny ':all'; my @cmd = ( 'C:\program files\myprog\space invaders.exe', 'parameter 1', 'parameter 2 with spaces' ); my ($stdout, $stderr, $exit) = capture { system @cmd }; print "The return status was $exit\n"; print "The output was $stdout\n";

Replies are listed 'Best First'.
Re^2: Executing perl program from another perl program and capturing the output
by Anonymous Monk on Nov 25, 2014 at 03:14 UTC

    You don't want to use 8.3 names ...

    If they have anything resembling unicode you sure do want to use 8.3 if you got them :) otherwise you won't be able to read or execute that file

      Well, I'll have to take your word for that. If true, then Perl does not deserve to be used on Windows. Telling people to use 8.3 filenames at this stage of the game is a sad admission of defeat and a poor implementation.

        Well, I'll have to take your word for that. If true, then Perl does not deserve to be used on Windows. Telling people to use 8.3 filenames at this stage of the game is a sad admission of defeat and a poor implementation.

        Yeah, that statement is worthy of expletives Loops, but if we the win32 users don't despair, neither should you :)

        Since the beginning of windows, cmd.exe did not come with unicode by deafult... and cmd.exe is at the root of every application, its documented in perlport ... we users of win32 know there is always a little extra work to accommodate out platforms, we're better at portability programming than non-win32 programmers :)