#!/usr/bin/perl -w use strict; use Data::Dumper; my %hash=(); my $str; while () { chomp; /^>(\w+)/; $hash{$1} = $str; $str .= $_; #next; } print Dumper \%hash;