Because unless otherwise specified a foreach loop (which can also be spelled for as you've done) uses the usual default variable $_, and likewise if not given an explicit argument print prints the contents of said default variable.
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re: perl loop counter
by Fletch
in thread perl loop counter
by cutlass2006
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |