in reply to hash deref confusion: Intermediate Perl
But, in the next line, "@$self" is syntax for dereferencing an array reference, not a hash reference!
The construct you refer to is called a 'hash slice' -- see perldata#slices.
It assignes the 4 values derived from spliting $STANDINGS{$name} (or the four 0s from the constant) to the the four keys:
.qw[ wins places shows losses ]
That one line is (mostly) equivalent to:
$self->{wins} = $STANDINGS[ 0 ] || 0; $self->{places} = $STANDINGS[ 1 ] || 0; $self->{shows} = $STANDINGS[ 2 ] || 0; $self->{looses} = $STANDINGS[ 3 ] || 0;
|
|---|