while () { my ($key) = /^>?(\S+)/; local $/ = '>'; chomp(my $val = ); $val =~ s/\n//g; $hash{$key} = $val; }