Capture-Tiny icon indicating copy to clipboard operation
Capture-Tiny copied to clipboard

Unexpected extra line of output

Open ronsavage opened this issue 12 years ago • 3 comments

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?

ronsavage avatar Sep 25 '13 03:09 ronsavage

Errr, that ugly black line is actually a hash-prefixed comment of hyphens. Just ignore it.

ronsavage avatar Sep 25 '13 03:09 ronsavage

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.

dagolden avatar Sep 25 '13 11:09 dagolden

Hi David

On 25/09/13 21:01, David Golden wrote:

Was that capture or capture_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 say my $foo = capture { ... }.

So you don't really want to directly say the results of capture.

No :-).

Ron Savage http://savage.net.au/ Ph: 0421 920 622

ronsavage avatar Sep 25 '13 23:09 ronsavage