And for(;;) internally compiles to a while(){} continue{} construct which is pretty slow. If you have determined that the foreach loop is causing problems, you could resort to a regular while loop:
my $i = 0;
while($i++ < $#array) {
($x1, $y1) = ($array[$i] =~ m/\D(\D?\d+\D?\d*)\D(\D?\d+\D?\d*)\D/;
($x2, $y2) = ($array[$i + 1] =~ m/\D(\D?\d+\D?\d*)\D(\D?\d+\D?\d*)
+\s*\D/);
}
But the foreach loop is much easier to read, so unless it was absolutely necessary I'd stick with that one.
Makeshifts last the longest. |