Skip to content

Instantly share code, notes, and snippets.

@sbertrang
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sbertrang/9040413 to your computer and use it in GitHub Desktop.
Save sbertrang/9040413 to your computer and use it in GitHub Desktop.
\d matches more than just digits
#!/usr/bin/perl
use strict;
use warnings;
use open qw( :std :utf8 );
# http://www.fileformat.info/info/unicode/char/06f3/index.htm
# Unicode Character 'EXTENDED ARABIC-INDIC DIGIT THREE' (U+06F3)
printf( STDOUT "%s: %s: * 1024 = %d\n", m!\A\d+\z! ? "num" : "nonum", $_, $_ * 1024 )
for "1", "foo", "\x{6f3}"
;
__END__
$ perl utf8num.pl
num: 1: * 1024 = 1024
Argument "foo" isn't numeric in multiplication (*) at utf8num.pl line 8.
nonum: foo: * 1024 = 0
Argument "\x{6f3}" isn't numeric in multiplication (*) at utf8num.pl line 8.
num: ۳: * 1024 = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment