in reply to Re: Re: Looking up a hash by value
in thread Looking up a hash by value

See other nodes like yours. That map is an expensive one. Benchmark this instead:
my %rev; while ((undef, my $value) = each %forward) { $rev{$_} = 1; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Re: Re: Looking up a hash by value
by tomhukins (Curate) on Feb 26, 2001 at 14:20 UTC

    Thanks, I understand what you mean now.

    Interestingly, this is slightly slower than reverse for hashes with few key/value pairs (25), while ... each performs faster on my system for hashes with more than 1500 key/value pairs.

    Of course, I'm using simple data (integers) as my keys and values, so this benchmark may not test real world performance.

    The main reason I would use reverse is that I find it makes the code more readable.