$ perl -e 'print "there is no newline\n" if "foo\n" =~ /.*\z/' $ perl -e 'print "there is no newline\n" if "foo" =~ /.*\z/' there is no newline