From: "Beginner" <[EMAIL PROTECTED]> > On 9 Nov 2007 at 16:35, Jenda Krynicky wrote: > > > From: "Beginner" <[EMAIL PROTECTED]> > > > #!/bin/perl > > > > > > use strict; > > > use warnings; > > > use Data::Dumper; > > > > > > my @keys = qw(fe fi fo thumb); > > > my @valone = 1..4; > > > my @valtwo = 10..14; > > > my %hash; > > > @[EMAIL PROTECTED] = [EMAIL PROTECTED],@valtwo]; > > > > [...] creates an array reference. You want > > > > @[EMAIL PROTECTED] = ( [EMAIL PROTECTED],[EMAIL PROTECTED]); > > > > Probably. Though it will only set the values for 'fe' and 'fi', > > because I only specify two values. > > > > What I was attempting was to have each key to be assigned the > coresponding items from the array. So it might look like something > like: > > $VAR1 = { > 'fe' => [ > 1, > 10 > ], > 'fi' => [ > 2, > 11, > ], > 'fo' => [ > 3, > 13, > ], > 'thumb' => [ > 4, > 14, > ] > };
@[EMAIL PROTECTED] = map [$valone[$_], $valtwo[$_]] (0..$#valone); The map produces a list of arrayrefs, each referenced array contains one item from @valone and one from @valtwo. The 0th element of the result, the 0th elements of @valone and @valtwo, etc. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/