in reply to Re^4: reading files in @ARGV doesn't return expected output
in thread reading files in @ARGV doesn't return expected output

With multiple files then maybe what you want is a 3 dimensional array ?

#!/bin/perl/ use strict; use warnings; my $molec1 = "molec1"; my $molec2 = "molec2"; my $path = "/store/group/comparisons"; my @matrix; my @files; for my $i (1..3){ push @files, $path."/File-$molec1-cluster$i.out" } for my $j (1..2){ push @files, $path."/File-$molec2-cluster$j.out" } my @all = (); for my $filename (@files){ open my $fh,'<',$filename or die "Could not open $filename"; my @matrix = (); while (my $line = <$fh>){ next if ($line =~ /^#/); chomp $line; push @matrix,[split /\s+/,$line]; } close $fh; push @all,\@matrix; } my $matrices = scalar @all; for my $i (0..$matrices-1){ print $files[$i]."\n"; my $rows = scalar @{$all[$i]}; for my $r (0..$rows-1){ my $cols = scalar @{$all[$i][$r]}; for my $c (0..$cols-1){ print "$all[$i][$r][$c] " } print "\n"; } print "\n"; }
poj