First, there's no need for a triple negative. That's like saying:
my $$$a = \\$b;
just because you can.
And there's no need to put \D in a character class. It is, itself, a character class. Only put it in a character class if you intend to also add other things to it.
And though /g is useful in many situations (even in Scalar context), it's not helping you here because you're simply looking for a nondigit somewhere in the string. Regular expressions look through the whole string automatically, for one instance of a match, and return true as soon as they find that instance. If you had a situation where you cared about multiple matches, you would use /g, but you only want to reject the string if it contains one or more. You don't really care about the "or more" part. One is enough to be a problem, so just get rid of the /g; it wasn't working for you in that example anyway.
So after all's said and done, your code should look like this:
my $match = '\D';
print "non digits found\n" if $str =~ $match;
Hope this helps!
Dave
"If I had my life to do over again, I'd be a plumber." -- Albert Einstein |