in reply to Re: Code clarification - use of map and $$_
in thread Code clarification - use of map and $$_
++AnomalousMonk: that helped (me, anyway; don't know about the OP). That was my first guess, but my initial experiments with the OP code didn't mesh. But I later saw that the print went to OUT, and forgot to redo a test to STDOUT. Thus I started thinking that it was a sub named END in a bout of horrible style. But I think you're right, it's an END block.
However, with this simplified code, I still only see the FIRST instance of the END block doing anything:
use strict; use warnings; $, = ","; $\ = "\n"; $" = ";"; my %r = ( 0 => 0, 1 => 0, 2 => 0, 3 => 0 ); foreach (1..10) { my $x = $_ % 4; ++$r{$x}; sub END { print __LINE__, "sub END block", $x, $r{$x} }; } foreach(1 .. 10) { my $x = $_ % 4; print "$_ => $x => $r{$x}"}; print __LINE__, "END OF SCRIPT"; __END__ __OUTPUT__ 1 => 1 => 3 2 => 2 => 3 3 => 3 => 2 4 => 0 => 2 5 => 1 => 3 6 => 2 => 3 7 => 3 => 2 8 => 0 => 2 9 => 1 => 3 10 => 2 => 3 17,END OF SCRIPT 13,sub END block,1,3
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Code clarification - use of map and $$_
by AnomalousMonk (Archbishop) on Aug 09, 2016 at 15:28 UTC | |
|
Re^3: Code clarification - use of map and $$_
by pryrt (Abbot) on Aug 09, 2016 at 15:21 UTC |