in reply to Re^5: hex numbers
in thread hex numbers
That is what regular expressions are for:
local $_ = <STDIN>; chomp; my $hexnum = undef; $hexnum = eval "0x$1" if (m/^(?:0[xX])?([[:xdigit:]]+)$/); die "bad input" unless defined $hexnum;
Do not assume that the input meets your constraints — verify that the input meets your constraints! :-)
|
|---|