RE: Fastest method with a hashes...

2002-05-20 Thread Jeff 'japhy' Pinyan
On May 20, Nikola Janceski said: >This returns an odd number of elements: > >my %BYNAME = map { { "$ALL{$_}" => "$_" } } keys %ALL; You've got an extra set of { } in there. The inner one makes a hash reference, so if the hash has an odd number of keys, there will be an odd number of hash refere

Re: Fastest method with a hashes...

2002-05-20 Thread Jonathan E. Paton
--- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > ... > %byname = reverse %hash; Thanks John, that was the concise way to do it. Time for someone to do the benchmarks between this and the "while each" method I did. I *think* the latter will be faster (or at least less memory hungry) - but perha

RE: Fastest method with a hashes...

2002-05-20 Thread Jonathan E. Paton
> any ideas on how to create reverse hash quick? > ... while (my ($key, $value) = each %hash) { warn "Collision during inversion!" if exists $hash{$value}; $new_hash{$value} = $key; } of course, if you are doing this a lot then you need a different structure. The solution is obv

Re: Fastest method with a hashes...

2002-05-20 Thread John W. Krahn
Nikola Janceski wrote: > > That would be my grep method > > $pc = grep $testvalue eq $HASH{$_}, keys %HASH; > > any ideas on how to create reverse hash quick? > This returns an odd number of elements: > > my %BYNAME = map { { "$ALL{$_}" => "$_" } } keys %ALL; $ perl -le' %hash = ( PC1 => "Nik

RE: Fastest method with a hashes...

2002-05-20 Thread Nikola Janceski
found it... some damn values were empty. > -Original Message- > From: Nikola Janceski [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 5:17 PM > To: 'Timothy Johnson'; Nikola Janceski; Beginners (E-mail) > Subject: RE: Fastest method with a hashes... >

RE: Fastest method with a hashes...

2002-05-20 Thread Nikola Janceski
imothy Johnson [mailto:[EMAIL PROTECTED]] > Sent: Monday, May 20, 2002 5:08 PM > To: 'Nikola Janceski'; Beginners (E-mail) > Subject: RE: Fastest method with a hashes... > > > > The only other thing I can think of that you haven't mentioned is just > cycling t

RE: Fastest method with a hashes...

2002-05-20 Thread Timothy Johnson
{$_} = $myvalue){ print "I've got a flying machine!\n"; } } -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Monday, May 20, 2002 2:03 PM To: Beginners (E-mail) Subject: Fastest method with a hashes... I have a hash as follows: PC1 => Niko

Fastest method with a hashes...

2002-05-20 Thread Nikola Janceski
I have a hash as follows: PC1 => Nikola Janceski PC2 => Some Moron PC3 => Some Other Moron etc.. I want to be able to get the key (PC#) using the value, what's the fastest method? What I can think of: a. have a reversed hash of the same info. b. use that funky module which makes hashes go both