$ cat > tfile line1 line2 line3 $ perl -Mstrict -we ' > my @error1 = do > { > open my $fh, q{<}, q{tfile} or die $!; > grep m{2}, <$fh>; > }; > print @error1 ? qq{match found : @error1} : qq{nothing\n};' match found : line2 $ cat > tfile line1 line3 $ $ perl -Mstrict -we ' > my @error1 = do > { > open my $fh, q{<}, q{tfile} or die $!; > grep m{2}, <$fh>; > }; > print @error1 ? qq{match found : @error1} : qq{nothing\n};' nothing $