K
kg.google
I iterate over odd/even index elements from @array with the code below.
This is the inner most piece of a huge loop, so if there is a more
efficient way, it will make a big difference ;-) Is there a better
way? (relative element order must be maintained)
my $i = 0; # 0=odd, 1=even
foreach(grep $i++ % 2, @array)
{
}
By the way, @array is usually small (2 or 4 elements)
thanks,
Kiriakos
This is the inner most piece of a huge loop, so if there is a more
efficient way, it will make a big difference ;-) Is there a better
way? (relative element order must be maintained)
my $i = 0; # 0=odd, 1=even
foreach(grep $i++ % 2, @array)
{
}
By the way, @array is usually small (2 or 4 elements)
thanks,
Kiriakos