Unexpected extra line of output
This is for Perl v5.14.2:
!/usr/bin/env perl
use feature 'say'; use strict; use warnings;
use Capture::Tiny 'capture';
--------------------------
say capture{system('echo', 'Hello World')};
This outputs 2 lines. The 0 is unexpected:
Hello World 0
When using something like:
my($stdout) = capture{system('echo', 'Hello World')};
say $stdout;
Then the output contains just the 1 expected line.
Any ideas?
Errr, that ugly black line is actually a hash-prefixed comment of hyphens. Just ignore it.
Was that capture or capture_stdout? I suspect the latter.
The "0" is probably the return value of system. The capture commands return the output and the return value of the block so you can say my $foo = capture { ... }.
So you don't really want to directly say the results of capture.
Hi David
On 25/09/13 21:01, David Golden wrote:
Was that
captureorcapture_stdout? I suspect the latter.
Yes. I was switching the code back and forth between the 2.
The "0" is probably the return value of
system. The capture commands return the output and the return value of the block so you can saymy $foo = capture { ... }.So you don't really want to directly
saythe results ofcapture.
No :-).
Ron Savage http://savage.net.au/ Ph: 0421 920 622