my $foo = " bar"; if($foo =~ /\S/) { print "Whitespace only\n"; }