use strict; use warnings; for my $str ('', ' ', '\0', "\n", undef) { print "matched '$str'\n" if $str =~ /\A\z/; } #### matched '' Use of uninitialized value $str in pattern match (m//) at C:\Users\Peter\Delme~~\PerlScratch\noname.pl line 8. matched '' Use of uninitialized value $str in concatenation (.) or string at C:\Users\Peter\Delme~~\PerlScratch\noname.pl line 8.