L
Lord0
Hi there,
Is there a magic variable which will return the current index of an array if
used in a loop?
i.e.
# I don't like
my $i=0;
for(@my_array){
# do something using $i
$i++;
}
# I would like to
for(@my_array){
# do something using "magic" variable
# So in third iteration of loop the magic variable would be 2 etc
}
I know about $[ and $# but they don't do the do...........
Cheers
Lord0
http://ltierney.demon.co.uk
Is there a magic variable which will return the current index of an array if
used in a loop?
i.e.
# I don't like
my $i=0;
for(@my_array){
# do something using $i
$i++;
}
# I would like to
for(@my_array){
# do something using "magic" variable
# So in third iteration of loop the magic variable would be 2 etc
}
I know about $[ and $# but they don't do the do...........
Cheers
Lord0
http://ltierney.demon.co.uk