http://qs1969.pair.com?node_id=1230321


in reply to Re: Performing addition on hex value extracted from a string
in thread Performing addition on hex value extracted from a string

my ($addr) = $line1 =~ /addr:(0x(?:[[:xdigit:]]{2})+)/;

If the hex value really is an address as  'addr' suggests, is there any guarantee the hex digits will always be paired, i.e., always be an even number of digits? If they are not paired, won't the lack of a boundary assertion sometimes cause an incorrect value to be extracted from the string?

c:\@Work\Perl\monks>perl -wMstrict -le "my $line1 = 'addr:0xabcde'; my ($addr) = $line1 =~ /addr:(0x(?:[[:xdigit:]]{2})+)/; print qq{'$addr'}; " '0xabcd'


Give a man a fish:  <%-{-{-{-<