#/bin/perl/ use strict; use warnings; use autodie; my $molec = "1ac6"; my $cluster; my $times; my $input; my $path = "/media/RAIDstorage/home/athina/dist-analysis/${molec}/time +series/test"; my $line; my @files; @files = `ls $path\/$molec-times*`; foreach (@files) { my $a; my $b; my $m_avrg; my @m_avrg; undef @m_avrg; my @list; my $list; my $aver; /${molec}-times-(\d+)-clust(\d{1})/; $times = $1; $cluster = $2; open $input, '<', "$path\/${molec}-times-${times}-clust${cluster}.out +" or die $!; while ($line = <$input>) { chomp $line; push @list, [split/\s+/, $line]; } # while input close $input; for ($a=0; $a<=2; $a++) { for ($b=0; $b<=2; $b++) { #print "$list[$a][$b] "; # check matrices $m_avrg[$a][$b] = ($m_avrg[$a][$b] + $list[$a][$b]); print "$m_avrg[$a][$b] \n"; } print " \n"; } print "average\n"; for ($a=0; $a<=2; $a++) { for ($b=0; $b<=2; $b++) { $m_avrg[$a][$b] = $m_avrg[$a][$b] / 4; print "$m_avrg[$a][$b] "; } print "\n"; } } # foreach file in loop