Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Using IPC::Open3 instead of backtick operator

by Marshall (Canon)
on Jun 10, 2016 at 20:55 UTC ( [id://1165367]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using IPC::Open3 instead of backtick operator
in thread Using IPC::Open3 instead of backtick operator

My open will capture both the STDERR and STDOUT messages. See below code...

Main:

#!/usr/bin/perl use warnings; use strict; open (IN, '-|', 'perl PrintStdoutStdErr.pl') or die "$!"; while (<IN>) { print; } __END__ prints: this went to STDERR this went to STDOUT
PrintStdoutStdErr.pl
#!/usr/bin/perl use warnings; use strict; $|=1; print STDOUT "this went to STDOUT\n"; print STDERR "this went to STDERR\n";
I actually wouldn't worry about Perl critic on an "ls" command.

Replies are listed 'Best First'.
Re^4: Using IPC::Open3 instead of backtick operator
by Anonymous Monk on Jun 10, 2016 at 20:59 UTC
    My open will capture both the STDERR and STDOUT messages.

    No, it doesn't.

    $ cat main.pl #!/usr/bin/perl use warnings; use strict; open (IN, '-|', 'perl PrintStdoutStdErr.pl') or die "$!"; while (<IN>) { chomp; print "\"$_\"\n"; } $ perl main.pl 1>out 2>err $ cat out "this went to STDOUT" $ cat err this went to STDERR

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1165367]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found