in reply to Re: Handling undefined string content
in thread Handling undefined string content

Drat. jeroen took off just as I spotted his possible typo.
Hopefully, he'll correct it.
if (length(substr($var, index($var, ' '), rindex($var, ' ')+1)) == len +gth($var) { Dosomething(); }

Not that I'd advocate that approach. The rindex+1, could have length instead, but I still wouldn't use it over the regex answers

On to what's wrong with jeroen's statement: sorry
substr($var,' ') will always return the full string since ' ' will be interpreted as 0.
use warnings will point out not a numeric argument.
Also since length returns numeric values, == instead of eq should be used. Not that this would happen, but "010" eq "10" is false while "010" == "10" is true.

Update: Ah good. He saw it, the length x space works, the tr solution does not. tr returns the number of matches to a scalar. So if you had 10 spaces in your string, you would get the number 10.
And of course these would only we applicable to space answers, not on any whitespace.