use strict; use warnings; use List::Util qw(first max); while(){ (my $probeset_id, my $origin, my $probeseq, my $pip, my $gc, my $affyscore) = split("\t", $_); push (@{$hash_F2_1{$origin}}, $pip); # This makes a hash of multiple value for each probeset ID foreach my $origin (sort keys %hash_F2_1){ foreach my $position (@{$hash_F2_1{$origin}}){ my $max = max values %hash_F2_1; print "$origin\t$max\n"; } }