in reply to pruning of empty arrayrefs in nested array

Thank you very much to everybody. Both solutions work very well, that with grep and that with map. I have tried to make the map one work with foreach, but I gave up, because of the inability of erasing the empty references without leaving the slots undefined. Again, thank you. Best regard Luca
sub prune_with_map { my $aref = shift; @{ $aref } = map { if( ref( $_ ) ) { if( @{ $_ } ) { prune_with_map( $_ ); } else { (); } } else { $_; } } @{ $aref }; return ( $aref ); } sub prune_with_foreach { my $aref = shift; my $count = 0; foreach ( @$aref ) { if( ref( $_ ) ) { if( @{ $_ } ) { prune_with_foreach( $_ ); } else { delete $aref->[ $count ]; } } else { $_; } $count++; } return ( $aref ); }