On Tue, Mar 4, 2008 at 8:06 PM, MK <[EMAIL PROTECTED]> wrote:
> On 03/04/2008 03:41:44 PM, yitzle wrote:
>
>  -> I'd use a RegEx and test to see if the string is made up entirely of
>
> -> integers.
>  ->   print "The variable containing $p is an interger\n" if ($p =~
>  -> /^[0-9]+$/);
>
>  yitzle would seem to have the most foolproof solution.  The only
>  problem would be if $p="+1" which i would consider +1 an integer.
>
>  incidentally /^\d+$/ amounts to the same thing.
snip

Nope, due to addition of Unicode support in recent versions of Perl it
will also match "\x{1814}" the Mongolian digit 4.  The \d character
class is not the same as [0-9], it matches all number characters,
including those in other scripts.  If you want to only
0,1,2,3,4,5,6,7,8,9 you need to say [0-9].

perl -le 'print "\x{1814}" =~ /\A\d+\z/ ? "t" : "f"'

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to