I have this code and wonder why it works this way with a '@' preceding the hash:
#!/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;
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 );
# I thought it would need a $!
$hash{@keys} = @values;
print Dumper \%hash;
Why do you need the '@' preceding the hash name and not a '$'?