my $file = 'data.txt'; open READ, $file || die "Cannot open $file: $!\n"; my %hash; while (){ chomp; my ($id, $seq, $length, $gc, $cai) = split /\s+/, $_; $hash{$id} = [ $seq, $length, $gc, $cai ]; } close (READ); foreach (keys %hash){ print $_, "\t", %hash->{$_}[1], "\t", %hash->{$_}[2], "\n"; }