in reply to Subroutine Subtrefuge

First of all the following doesn't make sense. sub is called with the same parameters every time.

foreach (@temp) { sub($x0, $y0, $x1, $y1, @temp) } }
But lets see if I understand your problem. It seems you have an unnecessary loop there. I commented that out. Also I changed your inner loops slightly, they have to stop looping after they get to the last 4 values.

Now all there is left to do is to take your best attempt and wrap the corrected code for the other hash around it, substituting $x2...$y3 with @temp. I put the inner loop into a sub, makes it easier to compare to your version

foreach my $key (keys %other_hash) { # foreach (@{$other_hash{$key}} # { for (my $i=0; $i<=@{$points_by_name{$key}}-4; $i+=2) { innerloop( @{$other_hash{$key}}[$i..$i+3] ); } # } }
and
sub innerloop { my ($x2,$y2,$x3,$y3)= @_; foreach my $key (keys %points_by_name) { # foreach (@{$points_by_name{$key}} # { for (my $i=0; $i<=@{$points_by_name{$key}}-4; $i+=2) { sub(@{$points_by_name{$key}}[$i..$i+3], $x2, $y2, $x3, + $y3) } # } } }
Note I didn't test this. Might still be some bug in it.

About your 'keeping track' problem: You have $key, you have $i, what else do you need to know about the line you are evaluating? Pass them into the sub if the sub needs to know