in reply to Validating Hex Numbers
If you don't care about if Perl thinks it's portable and/or too large to be an integer then you can make it not warn about that through the warnings pragma (no warnings 'appropriate category';, see perllexwarn) or by handling the warnings in the warn hook:sub is_hex { my ($s) = @_; local $SIG{__WARN__} = sub { die }; return eval { scalar hex $s; 1 }; }
Hope I've helped,local $SIG{__WARN__} = sub { /non-portable/i or /overflow/i or die for @_; };
|
|---|