#!/usr/bin/perl use strict; use warnings; my $file = 'input.txt'; my %hash; open my $fh, '<', $file or die $!; while( my $line = <$fh> ){ chomp $line; my @zahlen = split /,/, $line; for my $i ( 0..$#zahlen ){ push @{$hash{$i}}, $zahlen[$i]; } } close $fh; for my $j ( sort{ $a <=> $b }keys %hash ){ print join("\t", @{ $hash{$j} }),"\n"; }