in reply to Re^2: when do i know that the iterator for a hash was reseted
in thread when do i know that the iterator for a hash was reseted
I'd say the thrust is still valid, though, assuming you are the one constructing the hash in the first place. That is, why not, at the point you create the hash key, normalize it to lowercase with:if (lc($name) eq lc($string)) {
and now a test for exists would only even have to test for a lower-case version of the string_in_question. If your hash is at all sizeable, I'd think that using a little extra RAM to store the original key would be beneficial: you could avoid iterating through the keys every time you need to do this check.my %hash; my $next_key = 'What_I_am_looking_for Irrelevant_String'; my $data_for_next_key = 'xxx'; $hash{ lc $next_key } = [ ($next_key, $data_for_next_key) ]; print "Value associated with '$next_key' is '", $hash{ lc $next_key }->[1], # or $hash{ lc $next_key }[1] "'\n";
This assumes that you don't have duplicate entries because of case, i.e. it will have to be okay that $hash{ aBc } clobbers $hash{ ABC }.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: when do i know that the iterator for a hash was reseted
by rminner (Chaplain) on Apr 22, 2006 at 10:37 UTC |