I am new to perl. I need to understand how can I map one array (as keys) to another (as values) to result in a hash using foreach loop:
@one = ("A", "B", "C");
@two = ("a", "b", "c");
I wrote the following code but it does not work when I slice the hash??
%hash;
foreach $i (one) {
print $i, "=>" , $ii = shift @two, "\n"
}
@oneand the values the corresponding elements of@two? - Shawnfor my $i (0..$#one) { $hash{$one[$i]} = $two[$i] }. But there are much better ways, like in @Shawn's answer. - zdimuse warnings;anduse strict;at the beginning of programs. - zdim