more useful options | |
PerlMonks |
Re^3: How to pass data as STDIN to Capture::Tinyby haukex (Archbishop) |
on Jan 02, 2017 at 18:16 UTC ( [id://1178809]=note: print w/replies, xml ) | Need Help?? |
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:
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,
In Section
Seekers of Perl Wisdom
|
|