@rot_mat #### $rot_mat[0][0] = 'foo'; #### return \@rot_mat; #### my $aref = &first_sub(); #### my $bar = $aref->[0]->[0]; # hard to read #### my $baz = $aref->[0]; my $quux = $aref->[1]; # now $baz is a reference to the anonymous array Perl created # for the first element of @rot_mat when you assigned a value # to $rot_mat[0][0] in the first sub say 'yep' if $baz->[0] eq 'foo'; #### foreach my $anon_array ( @{ $aref } ) { # dereference the main array foreach my $value ( @{ $anon_array } ) { # dereference the anon array say 'yep' if $value eq 'foo'; } } ####