my $L = $tabs->[10]; while ($L) # ie, as long as $L has a value { $m->[ $L->[1] ] = $L->[2]; # assign the 3rd value referenced by $L to the arrayref $m # (indexing with the 2nd value referenced by $L) $L = $L->[0]; # assign $L the first value of the arrayref its referencing # (or undef if not available) }