awohld has asked for the wisdom of the Perl Monks concerning the following question:
I have this code and wonder why it works this way with a '@' preceding the hash:
I'd expect it to be as below:#!/usr/bin/perl -w use strict; use Data::Dumper; my %hash; my @keys = qw ( one two three ); my @values = qw ( 1 2 3 ); # What's with the @ symbol and not a $? @hash{@keys} = @values; print Dumper \%hash;
Why do you need the '@' preceding the hash name and not a '$'?#!/usr/bin/perl -w use strict; use Data::Dumper; my %hash; my @keys = qw ( one two three ); my @values = qw ( 1 2 3 ); # I thought it would need a $! $hash{@keys} = @values; print Dumper \%hash;
Back to
Seekers of Perl Wisdom