Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: How to pass data as STDIN to Capture::Tiny

by haukex (Archbishop)
on Jan 02, 2017 at 18:16 UTC ( [id://1178809]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to pass data as STDIN to Capture::Tiny
in thread How to pass data as STDIN to Capture::Tiny

Hi,

but you can't trust the exit value returned as the 3rd output value of capture and must instead inspect $?

I'm guessing what you're comparing kcott's code to is this example from the Capture::Tiny doc:

($stdout, $stderr, $exit) = capture { system( $cmd, @args ); };

In that code, the reason that you get $? stored into $exit is that system returns the same thing as $?, and capture returns the return value(s) from the block of code. Since in kcott's code the last statement in the block is print, its return value is what capture returns as the 3rd return value. If you wanted to use the above pattern of getting $? as the 3rd return value, just change kcott's code like this: sub run_external_command { ...; $? }.

Hope this helps,
-- Hauke D

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 01:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found