Sunday, January 25, 2015

Select rows Perl

#!/usr/bin/perl
use strict;
use warnings;
use 5.010;

my $file = 'matrixin.txt';
my @data;
open( FILE, $file ) or die "Can't open file '$file': $!";
while( ) {
chomp;
my @row = split;
push @data, \@row;
}
close( FILE );


#Print output
for my $i (1..2)  #memilih baris ke 2 s/d 3
{
for my $j (0..$#{$data[0]})
{
   print "$data[$i][$j]","\t";
}
   print "\n";
}

No comments: