use warnings; use strict; use Data::Validate qw(:math); my @data = qw(1234 ABCD 0x1234 foo 0xABCD bar); foreach my $val (@data) { if (defined(is_hex($val))) { print "$val\tis hex"; } else { print "$val\tis not hex"; } } __END__