$line1 = "this is an example"; $line2 = "this is another example,"; $line3 = "this is yet another example "; $line4 = "despite what you think this is not an example, "; if ($line1 !~ /.*,\s*$/) { print "MATCHED : $line1\n"; } else { print "MISMATCH: $line1\n"; } # ... repeated for $line2 $line3 and $line 4 ########################################################## # Output #MATCHED : this is an example #MISMATCH: this is another example, #MATCHED : this is yet another example #MISMATCH: despite what you think this is not an example, ##########################################################