use strict; use warnings; for my $str ('', ' ', '\0', "\n", undef) { print "matched '$str'\n" if $str =~ /\A\z/; }