Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
im not having much success when trying to define hash keys to be hexadecimal values. i can demonstrate the problem with this small code fragment...
$hash{"\x61"} = 'a'; print $hash{"\x61"} . "\n"; #prints 'a' print $hash{97} . "\n"; #null output
my naive question (not being a perlmonk) - should not the key value for $hash{"\x61"} be identical to $hash{97} - and therefore the outputs be the same? assuming, as i do that "\x61" equates to decimal 97. i do not understand why both print statements yield different outputs. i would have thought/expected that both print statements should have yielded 'a' as the output.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash key confusion
by davido (Cardinal) on Mar 24, 2014 at 20:44 UTC | |
|
Re: hash key confusion
by BrowserUk (Patriarch) on Mar 24, 2014 at 20:46 UTC | |
|
Re: hash key confusion
by Kenosis (Priest) on Mar 24, 2014 at 20:40 UTC | |
|
Re: hash key confusion
by locked_user sundialsvc4 (Abbot) on Mar 24, 2014 at 20:55 UTC | |
by davido (Cardinal) on Mar 24, 2014 at 21:31 UTC | |
by locked_user sundialsvc4 (Abbot) on Mar 25, 2014 at 00:14 UTC |