Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Exiting backticks early

by salva (Abbot)
on Mar 07, 2018 at 19:23 UTC ( #1210471=note: print w/replies, xml ) Need Help??


in reply to Exiting backticks early

Open the child process as a pipe, read as many lines as you want, then kill it.
my $pid = open my $fh, '-|', $cmd, @args; my @ten_lines; for (0..9) { my $line = <$fh> // last; push @ten_lines, $line; } kill TERM => $pid;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1210471]
help
Chatterbox?
[marto]: a grain of sand or dust in the keyboard, replace the motherboard. No we can't transfer your data for you

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2018-07-23 10:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (462 votes). Check out past polls.

    Notices?