in reply to Re: hash key confusion
in thread hash key confusion
Which is better?
# This? if( exists $hash{ sprintf "%#x", ord('a') } ) { ... } # or this? if( exists $hash{a} ) { ... }
I'd say that we don't know enough about his needs to make the determination that he ought to be storing stringified hexadecimal values as hash keys. There may be specific cases where that's useful, but in the general case it smells bad to me.
It almost seems like he's trying to create a hash that crossreferences hex values with literal characters. That's working too hard, when chr, ord, and sprintf already have the conversions down pat.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: hash key confusion
by locked_user sundialsvc4 (Abbot) on Mar 25, 2014 at 00:14 UTC |