<?xml version="1.0" encoding="windows-1252"?>
<node id="996678" title="How to save first two columns of an array into another array" created="2012-10-01 11:29:30" updated="2012-10-01 11:29:30">
<type id="115">
perlquestion</type>
<author id="955048">
zing</author>
<data>
<field name="doctext">
Hi all ,
I have this data file
&lt;p&gt;b c a&lt;/p&gt;
&lt;p&gt;a c d&lt;/p&gt;
&lt;p&gt;d e b&lt;/p&gt;

And this code reads this data file into a 2d array.
&lt;code&gt;
use strict;
use warnings;
use Data::Dumper;
# use PDL;
my @S;
 while (&lt;&gt;) {
        push @S, [ split ];
    }
print "-----TRIPLETS-------\n";
print Dumper \@S;
print "\n$S[0][1]\n";
# Find the number of vertices
my @L;
for my $i ( 0 .. $#S ) {
for my $j ( 0 .. $#{ $S[$i] } ) {
#print "elt $i $j is $S[$i][$j]\n";
push (@L,$S[$i][$j]);
}
}&lt;/code&gt;
Now what I want is another array which reads only first two columns of the array @S.
&lt;p&gt;b c &lt;/p&gt;
&lt;p&gt;a c &lt;/p&gt;
&lt;p&gt;d e &lt;/p&gt;</field>
</data>
</node>
