use Modern::Perl; no warnings qw /uninitialized /; my @result; while () { chomp; my ($index, $value) = split /\t/; $result[$index] = $value; } $result[50] = 0 unless $result[50]; while (my ($index, $value) = each @result) { next if $index == 0; say "$index\t", $value+0; } __DATA__ 33 5 34 7 36 7 37 8 38 0