# get your data into a string: my $data = join '', ; # declare a hash variable my %secs; # use a regex match to get the bits while ($data =~ m|<([^>]+)>([^<]+)|g ) { $secs{$1} = $2; } print "Regex Method\n"; print "\nSection: '$_'\n", $secs{$_} for keys %secs; # or use XML::Simple to parse it (generally better) ... use XML::Simple; my $hash = XMLin($data); print "\n\nXML Method\n"; print "\nSection: '$_'\n", $secs{$_} for keys %$hash; __DATA__ blah1 blah1 blah2 blah2 blah3 blah3