http://www.perlmonks.org?node_id=996692


in reply to How to save first two columns of an array into another array

On a side note, I just want to point out that the code:

# Find the number of vertices my @L; for my $i (0 .. $#S) { for my $j (0 .. $#{$S[$i]}) { push(@L, $S[$i][$j]); } }

can be simplified down to:

my @L = map { @$_ } @S;

since it’s just flattening a 2-dimensional list into a 1-dimensional list.

I know only too well how hard it is to switch from thinking in C to thinking in Perl. But persevere, it’s worth the effort!

Hope that helps,

Athanasius <°(((><contra mundum