On May 23, Jos Boumans said:

>Or a really one:
>
>if ($x =~ /\D/) {
>    print "found non digit, do not pass go, no 20 grands for you";
>} else {
>    print "good boy";
>}
>
>where \D stands for NON digits

The only problem is that "" passes that regex.  For that reason, I would
suggest something like:

  if (length($x) and $x =~ /\D/) { fail() }

or

  if ($x !~ /^\d+\z/) { fail() }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
** I need a publisher for my book "Learning Perl's Regular Expressions" **

Reply via email to