Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I mean I see what happens here:my @fields = qw( name email ); my %results; @results{@fields} = ();
I'm just not sure why it works. How does @results resolve to %results? Apparently the use of {} must force some context since normally @results and %results refer to different variables. Thanks.use strict; use warnings; use Data::Dumper; my @fields = qw( name email ); my %results; print "Before: ", Dumper(\%results); @results{@fields} = (); print "After: ", Dumper(\%results); __END__ Before: $VAR1 = {}; After: $VAR1 = { 'email' => undef, 'name' => undef };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash usage question
by Enlil (Parson) on May 23, 2003 at 23:24 UTC | |
|
Re: Hash usage question
by chromatic (Archbishop) on May 24, 2003 at 00:34 UTC |