#!/usr/bin/perl -w use strict; use Data::Dumper; $|++; my @AoA = ( undef, [1, 2], undef, [3, 4]); my @flat = map{defined (@$_) ? @$_ : ()}@AoA; print join (",",@flat),"\n"; # prints: 1,2,3,4 my $AoAref = \@AoA; @flat = map{ defined (@$_) ? @$_ : () }@$AoAref; print join (",",@flat),"\n"; # prints: 1,2,3,4 =so far prints:... 1,2,3,4 1,2,3,4 =cut @AoA = ( undef, [1, undef], undef, [3, 4]); $AoAref = \@AoA; # "undef" is a legal Perl value. # to handle this idea of an undef value within # an defined array (undef is a legal Perl value)! Yes, use grep. # # my map filters out "undefined references to arrays" # within an AoA, I would use grep to filter # that undesired "undef" value out if what is meant # a value within in an array. # as shown before: grep{} map{}.