in reply to foreach count variable

As it is, there is currently no implicit variable available to serve your purpose - There was the proposal of such a variable made in RFC120 and RFC262 for Perl 6 but this has been rejected by Larry - See Apocolypse 4, specifically here and here.

The only way to implement such a counter is to loop by index, rather than value - For example:

foreach my $count ($[..$#bar) { print $count, " -> ", $bar[$count], "\n"; }

Not quite as pretty or flexible, but the introduction of implicit loop variables would also mean the introduction of additional construct overhead.

 

perl -e 'print+unpack("N",pack("B32","00000000000000000000000111100100")),"\n"'