use strict; use warnings; my %FASTAhash; open my $file, ') { next if !/(>[^ ]+) /; chomp( $FASTAhash{$1} = $' ) if !$FASTAhash{$1} or length $' > length $FASTAhash{$1}; } close $file; print "$_ $FASTAhash{$_}\n" for keys %FASTAhash;