use warnings; use strict; use Data::Dumper; ; #remove the heading if not needed my @data; my $counter; while(){ chomp; $counter = 0; for (split/\s+/,$_){ push @{$data[$counter++]},$_; } } print Dumper \@data; __DATA__ METHOD 0TM 1TM 2TM >2TM method1 3 68 18 10 method2 3 80 10 6 method3 3 87 9 1 method4 5 83 9 3 method5 6 75 15 4 method6 14 77 6 3 method7 12 82 2 3 method8 9 84 3 3 method9 13 68 16 3 method10 5 65 20 9 method11 9 64 20 7 method12 5 68 18 9 method13 6 82 9 2 method14 11 79 8 2 method15 6 69 20 5 method16 5 80 11 3 method17 1 68 17 14