in reply to Populating a hash with two arrays

And there's the brain-dead method:
my %things; for (my $i = 0; $i < @people; $i++) { $things{$people[$i]} = $jobs{$i}; }

Replies are listed 'Best First'.
Re: Re: hashes
by mirod (Canon) on Dec 03, 2002 at 12:54 UTC

    This would be brain-dead only for Monks with a C background ;--)

    A little more perlish would be a loop similar to broquaint's map:

    my %hash; for my $i (0..$#people) { $hash{$people[$i]} = $jobs[$i]; }

    If you don't care about emptying @jobs you can also do:

    my %hash; foreach my people (@people) { $hash{$people}= shift @jobs; }

    But really the hash slice is the most compact way to do it.