in reply to Perl System('') question
And another alternative is to use open:
my $result; # first open or die open my $eject, '-|', 'eject -n' or die "Can't eject: $!\n"; # Then read in lineby line while (<$eject>) { next unless /^device is/; # until the result is found $result= $_; last; } # done close $eject;
Especially when filtering output, I prefer this method because you can loop over the output line by line and react as soon as you found your searched input.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl System('') question
by pobocks (Chaplain) on Nov 29, 2008 at 10:26 UTC | |
by ikegami (Patriarch) on Nov 29, 2008 at 12:40 UTC | |
by Skeeve (Parson) on Nov 29, 2008 at 23:44 UTC | |
by ikegami (Patriarch) on Nov 29, 2008 at 12:42 UTC |