in reply to counter issues
This is because $#array will be the index of the last element. By stopping at one less than this value, you know that $i + 1 will still be defined. This is not the best code, but I worked with what you had already shown - good job.for (my $i = 0; $i < $#array; $i++) { if ($array[$i] =~ m/\D{1}(\D?\d+\D?\d*)\D{1}(\D?\d+\D?\d*)\D{1}/ ) + { $x1 = $2; $y1 = $1; } if (($array[$i + 1] =~ m/\D{1}(\D?\d+\D?\d*)\D{1}(\D?\d+\D?\d*)\s* +\D{1}/ ) { $x2 = $2; $y2 = $1; } }
Cheers - L~R
|
|---|