for my $a1 (@x) { for my $a2 (@$a1) { for my $a3 (@$a2) { ... # hope you get the pattern by now } } }