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.
s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e