Hi, I'm trying to do the pattern match and extract the contents based on the back references on a file handler. But this doesn't seem to be working.Can someone explain me why the printing of file handler when used like print <FH> works & not the extraction part as i explained previously? Also suggest how this can be done in a single line of code instead of looping it in the while condition
open my $a,"<file"; print <$a>;# prints the file contents as expected print $1 if <$a> =~ m/(error.*)/; # Nothing printed though the files h +as the line containing error key word. my @b=<$a>;grep {$_ =~ /error/} @b;# This does the trick and wonderin +g why the above line doesn't work
In reply to Grepping the filehandler by arunkumar.rk141
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |