On Mon, 2007-08-13 at 07:47 -0700, Paul Lalli wrote:
> On Aug 13, 9:40 am, [EMAIL PROTECTED] (Ken Foskey) wrote:
> > On Sun, 2007-08-12 at 22:55 -0400, yitzle wrote:
> > > I got an array of values where the order is relevent, eg the ages of
> > > Alice, Bob and Charles, and I want to make a hash out of it. I got
> > > this code that does it:
> > >   my %ages = (alice => $r[0], bob => $r[1], charles => $r[2]);
> > > Is there a more elegent way to do it?
> >
> > This is not elegant in this example but it possibly is the answer you
> > are looking for.
> >
> >   my %ages{ 'alice', 'bob', 'charles'}  = @r;
> 
> I rather doubt the OP is looking for an "answer" that doesn't even
> compile.
> 
> I can only assume you meant:
> my %ages;
> @ages{'alice', 'bob', 'charles'} = @r;

You are right.

Apologies, my work laptop went to god and waiting for repairs so I don't
have the sample code :-(.

-- 
Ken Foskey
FOSS developer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to