Hi all,

On Mon, 23 Dec 2013 18:48:24 -0500
Shawn H Corey <shawnhco...@gmail.com> wrote:

> On Mon, 23 Dec 2013 15:02:13 -0800
> Kenneth Wolcott <kennethwolc...@gmail.com> wrote:
> 
> > open my $fh, @cmd, "|" or die "blah: $!\n"; fails, "Unknown open()
> > mode '5'"
> 
> If you use an array, it is _not_ sent thru the shell. Try the
> three-argument open:
> 
>     open my $fh, '-|', @cmd or die "blah: $!\n"; fails, "Unknown open()
>     mode '5'";

That won't get sent through the shell either:

[SHELL]

shlomif[homepage@default]:$trunk$ perl -E 'open my $fh, "-|", "make", "2>&1" or
die "Foo $!"'
make: *** No rule to make target '2>&1'.  Stop.
shlomif[homepage@default]:$trunk$ 

[/SHELL]

One needs to use a single command with a trailing "|" and making a wise
use of something like https://metacpan.org/release/String-ShellQuote (which I'm
not sure if it supports MS Windows properly, but should work on UNIXes):

shlomif[homepage@default]:$trunk$ perl -E 'open my $fh, "make 2>&1|" or die
"Foo $!"; while(<$fh>) {print} close($fh);'

You may also wish to look at https://metacpan.org/pod/IPC::Run .

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
List of Text Editors and IDEs - http://shlom.in/IDEs

Vizzini: He didn’t fall?! Inconceivable!
Inigo Montoya: You keep using that word. I do not think it means what you
think it means.
    — http://en.wikiquote.org/wiki/The_Princess_Bride_%28film%29

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to