print "Site $_ is $sites[$_-1]\n" for 1 .. 3;
would be better written as
print "Site $_ is $sites[$_-1]\n" for 1 .. @sites;
or
print "Site ", $_+1, " is $sites[$_]\n" for 0 .. $#sites;
Noone said the index needed to be printed:
print "$_\n" foreach @sites;
In reply to Re^2: looping through variables
by ikegami
in thread looping through variables
by keiusui
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |