#!/bin/perl/ use strict; use warnings; my $molec1 = "molec1"; my $molec2 = "molec2"; my $input1; my $input2; @ARGV = ();; my $i; my $j; my $path = "/store/group/comparisons"; my $line; my @columns; my $nextUnless = 2; # nr of lines to skip my $CountLines = 0; # total nr of lines in all files for ($i=1; $i<=3; $i++) { open $input1, '<', "$path\/File-${molec1}-cluster${i}.out" or die $!; push @ARGV, "$path\/File-${molec1}-cluster${i}.out"; } for ($j=1; $j<=2; $j++) { open $input2, '<', "$path\/File-${molec2}-cluster${j}.out" or die $!; push @ARGV, "$path\/File-${molec2}-cluster${j}.out"; } print "@ARGV \n"; # for testing; indeed correct files are printed ## now split and print my @list; my $list; my $a; my $b; while ($line = <>) { $CountLines += 1; next unless $. > $nextUnless; chomp $line; $line =~ s/^\s+|\s+$//g; push @list, [split/\s+/, $line]; @columns = split /\s+/, $line; print "@columns \n"; ## problem: prints all columns from specified files but ignores the $nextUnless specification - why? } close $input1; close $input2; for ($a=0; $a<=$#columns; $a++) { for ($b=0; $b<=$#columns; $b++) { print "$list[$a][$b] "; ## problem: prints only first file ($i=1) } print " \n"; }