use strict; use warnings; my %hash; my $id; while( my $line = ) { chomp $line; # if( $line =~ m/^>(.+?) / ) # changed to \S if( $line =~ m/^>(\S+)/ ) { $id = $1; } else { $hash{$id} .= $line; } }