Perl programming technique question?

Zeebo17

New member
Hi,

I've been trying to think of a way to do this for a while now and I'm pretty stuck. I'm programming in Perl, but this is more of a general technique question.

I have a list of $x[$i] and $y[$i] points that I want to output to a file. However, I don't want to output any double points so I have a list that contains the index number of the second occurrence of the points such as:
line[0]=5 #the second occurrence of a double point occurs at $i=5
line[1]=20 #the second occurrence of a double point occurs at $i=20
etc.

Now, I can't figure out how to cycle through the $i's and output the $x[$i] and $y[$i]'s to the outfile unless $i is equal to one of the $line[$j] values since it would then also have to cycle through all the $line[$j] values to check.

Any help would be greatly appreciated!
Thanks!
 
my $iLineCounter = 0;
XY_ELEMENT:
foreach my $iXYCounter (0..$#x)
{
if ($iXYCounter == $line[$iLineCounter])
{
$iLineCounter++; # get ready for next element of line
next XY_ELEMENT;
} # if
print "$x[$iXYCounter],$y[$iXYCounter]\n";
} # foreach XY_ELEMENT
 
Back
Top