![]() |
|
Just another Perl shrine | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
Almost through the Intermediate Perl book and came across code I do not understand and that was not explained clearly (seems to happen to me frequently in this book!). Here is the code:
As background: $self is a blessed hash reference. The method 'name' returns a scalar string. %STANDINGS is a hash that is associated with a DBM file. My question: I do not understand the line @$self{qw(wins places shows losses)} = @standings;
I see that @standings becomes a list of 4 numbers as a result from splitting on spaces. But, in the next line, "@$self" is syntax for dereferencing an array reference, not a hash reference! Further, the use of the "{" after this indicates a hash, but I have never seen a hash defined in this way. Are they actually saying that you can have a list of keys ("qw(wins places shows losses)") and set the values by setting this to the list "@standings"?? Really? PERL always seems to confound me with syntax! And when I cannot find the answer in perldocs etc. I just thorw up my hands and post it here! THANK YOU for being there monks! In reply to hash deref confusion: Intermediate Perl by live4tech
|
|