in reply to Grepping the filehandler

print $1 if <$a> =~ m/(error.*)/; # Nothing printed though the files h +as the line containing error key word.
print map /(error.*\n)/, <$a>;