######## this one fails to print ####### if($templine =~ /(ABC)/) {print " xxx xx";} ######## when this one works ###### if($templine =~ /(ABC)/) {print " xxx \n xx";} #### ?????????????????????????????????????????????????????? # This first one finds the matches of ABC ?????????????????????????????????????????????????????? foreach my $line (@_lines) { my $templine= $line; print "$templine"; # or print "$line"; if($templine =~ /(ABC)/){print "$1 = the line";} } #?????????????????????????????????????????????????????? # This next one doesn't find the matches of ABC #?????????????????????????????????????????????????????? foreach my $line (@_lines) { my $templine= $line; ############ print "$templine"; ############ # or print "$line"; if($templine =~ /(ABC)/){print "$1 = the line";} }