Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion faster execution

Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!ossa.telenet-ops.be!afrodite.telenet-ops.be.POSTED!not-for-mail
From: Bart Lateur <bart.lat...@skynet.be>
Newsgroups: comp.lang.perl.misc
Subject: Re: faster execution
Organization: MediaMind
Message-ID: <tj01rtgh830hnnrj6co8uv26e62qh4gie2@4ax.com>
References: <bce84cea.0109240016.6638f273@posting.google.com> <3dttqt4gm4leokkep17m2dibllab32b8is@4ax.com> <bce84cea.0109250053.4c2e7ac9@posting.google.com>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 44
Date: Tue, 25 Sep 2001 13:17:14 GMT
NNTP-Posting-Host: 213.224.7.206
X-Complaints-To: abuse@pandora.be
X-Trace: afrodite.telenet-ops.be 1001423834 213.224.7.206 (Tue, 25 Sep 2001 15:17:14 MET DST)
NNTP-Posting-Date: Tue, 25 Sep 2001 15:17:14 MET DST

venus wrote:

> What if I have an array that has different keys pointing to the same
>value?
>
>      %LOCATION = (
>	"GBE",   'Gaborone,,BC',
>        "GBC",   'Gaborone,,BC', 
>        "ADL",   'Amman,,JD', );

>       	%LOCATIONS = reverse %LOCATION;

...

>but this will eliminate those repeated values and only prints one of
>the associated key. Any other way to do it?
>
>Appreciate if you could help.

Indeed. That's the effect you get if you do:

	%hash = ( a => 1, a => 2, a => 3 );

all that is left is $hash{a} = 3 (the rightmost entry for "a" on the
list).

Instead, try something like:

	while(my($k, $v) = each %LOCATION) {
	     push @{$LOCATIONS{$v}}, $k;
	}


This will make an anonymous array entry for each old value, with all
associated keys pushed onto each.

You'll have to loop through them:

	foreach (@{$LOCATIONS{$location}} {
	    print OUTPUT_FILE "$_,$max1,$min1,$cond1\n";
	}

-- 
	Bart.