in reply to Running count in map
dragonchild has it though you'll have to ignore the confusing way he said it. You don't need a global, just a variable that is accessible. my()'d variables are perfectly acceptable here.
my $counter = 0; ... map { ++$counter; ... } ...
|
|---|