in reply to printing the line after grepping
Make the LHS an array and grep the line you want then print it.
$ 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 $
I hope this is helpful.
Cheers,
JohnGG
|
|---|