Re: easy (should be) perl question..

by John.ksi(at)webplus.net

 Date:  Fri, 26 Jan 2001 14:48 EST
 To:  hwg-servers(at)hwg.org
  todo: View Thread, Original
The following works for me.

> $str = "ABC";
> if ($str =~ /\D/)
>  {print "non-digit\n"; }
> else {print "digit\n"; }

I think the space characters inside your
slashes were causing the grief.

When setting your test string, you might want
to use quotes to avoid confusing yourself.
$str = 12x3
is not the same as
$str = "12x3"

But yes, if "ABC" is changed to "123" (incl the
double-quotes), the above will correctly report "digit".

BTW, altho' this question might not be *entirely* off-topic
for hwg-servers, it might be better off posted to a Perl
listserv anyway, IMHO.

-John Koch                               -  -  -  __o
Knowledge Systems, Inc.              -  -  - -  _ \<,_
<John.ksi(at)webplus.net>                   - -   (_)/ (_)
(A NET-FRIENDLY SIG. http://www.ncsa.uiuc.edu/Edu/ICG/pt1.ch2.Etiquette.html )

HWG: hwg-servers mailing list archives, maintained by Webmasters @ IWA