in reply to How to save first two columns of an array into another array
use strict; use warnings; use Data::Dumper; my @S; while (<DATA>) { push @S, [split]; } print "-----TRIPLETS-------\n"; print Dumper \@S; my @new = map { [@{ $_ }[0 .. 1]] } @S; print Dumper \@new; __DATA__ b c a a c d d e b
Output:
-----TRIPLETS------- $VAR1 = [ [ 'b', 'c', 'a' ], [ 'a', 'c', 'd' ], [ 'd', 'e', 'b' ] ]; $VAR1 = [ [ 'b', 'c' ], [ 'a', 'c' ], [ 'd', 'e' ] ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to save first two columns of an array into another array
by zing (Beadle) on Oct 02, 2012 at 14:05 UTC | |
by Athanasius (Archbishop) on Oct 02, 2012 at 14:25 UTC | |
by zing (Beadle) on Oct 02, 2012 at 15:19 UTC | |
by Athanasius (Archbishop) on Oct 03, 2012 at 03:38 UTC | |
by Anonymous Monk on Oct 02, 2012 at 14:27 UTC | |
|
Re^2: How to save first two columns of an array into another array
by Anonymous Monk on Oct 03, 2012 at 15:39 UTC |