in reply to Re: Re: Hashing multiple items
in thread Hashing multiple items

I actually want to do thngs the other way around. I want to have the zone as the key. So that I could say, print out out all the coorsinates in zone B1. Doing this -
$coordinates{$zone} = $a1,$a2,$b1,$b2)
will only allow my to save one coordinate for a particular zone. How do I save an arbitary bumber of coordinates for each zone?

Replies are listed 'Best First'.
Re: Re: Re: Re: Hashing multiple items
by CombatSquirrel (Hermit) on Nov 15, 2003 at 17:54 UTC
    Use an anonymous array as value:
    $coordinates{$zone} = [ $a1, $a2, $b1, $b2 ];
    Don't forget to dereference it when you read your coordinates back out:
    ($a1, $a2, $b1, $b2) = @{$coordinates{$zone}}
    Have a look at perlref and perlreftut.
    Hope this helped.
    CombatSquirrel.
    Entropy is the tendency of everything going to hell.