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] ); } # } }