Use a regex to see if the string contains only spaces (or whitespace, which also includes [ \t\r\f\n]):
print "Spaces only\n" if $var =~ /^ +\z/; print "Only whitespace\n" if $var =~ /^\s+$/; print "Whitespace or empty\n" if $var =~ /^\s*$/;
I used \z as the end of string anchor on the first one because you didn't specify whether the string was a line and a \n at the end might not be acceptable.
In reply to Re: Handling undefined string content
by danger
in thread Handling undefined string content
by akm2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |