##$lines contains the string to be matched if(/^>(\w+)\|(.*)?\|.*?$line.*\n/i){ $flag=1; print OUT "$_"; print "$1 == $2\n"; }