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
G'day Hauke,
Thanks for the feedback.
In my original test code (unpublished), I did have
close $cmd_pipe;
and I started to add some error checking. However, realising that I had no idea what the OP's external command was nor what error codes he might be looking for, I ripped that all out and just posted the part answering the original question. I probably should have left the close statement.
I don't know what autodie is doing under the hood; however, given that
open my $cmd_pipe, '|-', $external_command;
performs a fork, I suspect it's checking that (in its :threads category) and not doing anything in the :system category.
The only mention of pipe that I can see in autodie is that it's in the :ipc category. There's also one instance in IPC::System::Simple that I found somewhat humourous:
"Implementing the capture command involves dark and terrible magicks involving pipes, and one of them has sprung a leak."
[That's &IPC::System::Simple::capture, not &Capture::Tiny::capture.]
"perlipc: Using open() for IPC" has more information on error checking:
"Be careful to check the return values from both open() and close(). If you're writing to a pipe, you should also trap SIGPIPE. ..."
See also: "perlvar: Error Variables".
"However, nowadays I very much prefer to use more better-suited modules, ..."
Yes, Capture::Tiny wouldn't have been my first choice for this task; however, the OP mentions it four times in his single-paragraph post, so that's what I used.
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to pass data as STDIN to Capture::Tiny
by haukex (Archbishop) on Jan 03, 2017 at 14:17 UTC |