for (pair(zip($array1, $array2))) { my ($x, $y) = @$_; # It's often descriptive to name the values. ... } #### for ( sort { $a->[0] <=> $b->[0] or $a->[1] cmp $b->[1] } pair zip($array1, $array2) ) { my ($number, $char) = @$_; ... }