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