$ perl -E 'say oct "0x47"; say hex "0x47"' 71 71 #### $ perl -E 'say "0x47_not_hex" =~ /^0x/ ? "is hex" : "is NOT hex"' is hex $ perl -E 'say "0x47_not_hex" =~ /^0x[0-9a-fA-F]+$/ ? "is hex" : "is NOT hex"' is NOT hex