On Sep 5, Wiggins d'Anconia said:

>    my %vals;
>    @vals{@heads} = @vals;
>    return \%vals;

That's about as concise as you can get it.

>I was surprised that I could not avoid in the else doing the code in 3
>lines (obviously this isn't a huge deal).
>
>I was looking for something like:
>
>return my @vals{@heads} = @vals;

A my() declaration can only define an ENTIRE variable; my($x[2]) or
my($y{foo}) is a syntax error.

>\@vals{@heads} = @vals;

You can't assign like that.

I've not done benchmarks, but you could do:

  return { map +($heads[$_], $vals[$_]), 0 .. $#heads };

but I have a feeling it'd be slower... but you can never be sure.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to