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?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2018-04-20 22:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?