Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected extra line of output #13

Open
ronsavage opened this issue Sep 25, 2013 · 3 comments
Open

Unexpected extra line of output #13

ronsavage opened this issue Sep 25, 2013 · 3 comments

Comments

@ronsavage
Copy link

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
Copy link
Author

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

@dagolden
Copy link
Collaborator

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.

@ronsavage
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant