in reply to
Validating Hex Numbers
In addition to using an
anchored
(!) regex — but otherwise much as you wrote; you can also use the tr operator, like this:
length $h && $h !~ tr/0-9A-Fa-f//c;
[download]
This tests if $h doesn't contain any characters it shouldn't contain, and additionally, if there are any characters at all.
Comment on
Re: Validating Hex Numbers
Download
Code
In Section
Seekers of Perl Wisdom