in reply to Code clarification - use of map and $$_
The code
map {$x += $$_[0]; $y += $$_[1];} @{$r{$k};};is better written as:
for (@{ $r{$k} }) { $x += $_->[0]; $y += $_->[1]; }(Using map statement in void context in lieu of for is confusing.)
The dereferences are used because the structure is populated with array references. In other words, you have a hash of arrays (HoA). See perldata, perldsc.
Specifically, look at the matching statements:
The first populates the HoA with necessary data. The second one uses this data further down. Why HoA, why the need for array [ constructors ] and dereferences? Because one scalar was not enough. The original programmer needed to track two values and used the small arrays as tuples.push @{ $r{ ... } }, [ ... ]; ... for (@{ $r{ ... } }) { ... $_->[...] }
|
|---|