While
if( $_file_name !~ /^(\s*)$/ ) {
does handle the case of undef, it will cause a warning:
use warnings;
my $_file_name = undef;
if ($_file_name !~ /^(\s*)$/ ) {
print "ok\n";
}
__END__
Use of uninitialized value in pattern match (m//) at test.pl line 6.