in reply to converting a hash based matrix into an array based matrix

A quick observation:

while (my $key1 = shift @keys) {

is a potential bug. Consider what happens when @keys contains an element that Perl considers “false”:

3:19 >perl -wE "my @keys = ('a'..'c', '0', 'd'..'f'); say ''; while ( +my $key = shift @keys) { print qq[$key: ]; for (@keys) { print qq[$_ +] } say '' }" a: b c 0 d e f b: c 0 d e f c: 0 d e f 3:19 >

Better to play it safe by testing the size of the array before using shift:

3:19 >perl -wE "my @keys = ('a'..'c', '0', 'd'..'f'); say ''; while ( +@keys) { my $key = shift @keys; print qq[$key: ]; for (@keys) { print + qq[$_ ] } say '' }" a: b c 0 d e f b: c 0 d e f c: 0 d e f 0: d e f d: e f e: f f: 3:19 >

madM, I know this doesn’t address your question, but it may just save you some debugging down the track.

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,