open (INM,"$in_matrix") or die "Unable to open 'in_matrix': $!"; my @row=split (/\t/,readline(INM)); my @colfiles=(); my $max=$#row; foreach (0 .. $max) { open ($colfiles[$_],">$out_matrix.$_") or die "Failed on opening tempfile $_: $!"; print {$colfiles[$_]} shift (@row); }