if ($string !~ /\S/) { # $string is empty or composed entirely of spaces }