Re: pulling 1 key from a hash

2001-06-12 Thread Michael Fowler
On Tue, Jun 12, 2001 at 08:23:43PM -, Big Bird wrote: > I have a hash of zipcode-city pairs. Since a city may have more than one > zip code, the zipcodes are the keys. If there is exactly 1 value in the > hash that matches the city in the line of the file, I need to get the key > for that

Re: pulling 1 key from a hash

2001-06-12 Thread Rev. Jonathan T Sage
And, in an amzingly stupid manner, here's a correction to that code. sorry. --- "Rev. Jonathan T Sage" <[EMAIL PROTECTED]> wrote: > well, there may be more efficient means but something like this shoudl do the > trick. > > sub returnkey { > foreach $zipcode (keys %hash) { > if ( $hash{$zi

Re: pulling 1 key from a hash

2001-06-12 Thread Rev. Jonathan T Sage
well, there may be more efficient means but something like this shoudl do the trick. sub returnkey { foreach $zipcode (keys %hash) { if ( $hash{$control} eq $cityname ) { return $zipcode; } } } ~jon --- Big Bird <[EMAIL PROTECTED]> wrote: > I'm converting a massive fixed width file to a

pulling 1 key from a hash

2001-06-12 Thread Big Bird
I'm converting a massive fixed width file to a delimited one, but the file has some fields missing. It's my job to try to deduce the value of each missing field from another one present in that line of the file. One example is deducing the missing zip code given the city field. I have a hash