What I’m looking for is something like:
@list = qw(1 2 3 4 5 6); foreach (@list) { #perl magic goes here print 'i: $i, j:$j\n'; }
returns:
i:1, j:2 i:3, j:4 i:5, j:6
In response to a very good suggestion below, I need to specify that this script will run on someone else’s build server, and I’m not allowed to use any modules from CPAN. Standard Perl only.
I believe the proper way to do this is to use natatime, from List::MoreUtils:
from the docs:
Example:
This prints
The implementation of
List::MoreUtils::natatime: