{ my @records; local $/; # allow to read in whole file for(split /\s*\|--------------------------------------\|\s*/, ) { my %rec; next unless /\S/; #check for data for(split "\n", $_) { # split up the datum in a record my($key,$val) = split ':', $_, 2; # split the datum, the ,2 limits split to #only splitting the string into at most 2 pieces, saving further : $rec{$key} = $val; #store in hash } push @records, \%rec; # store recs in array } for(@records) { #iterate and print, you get the idea print "$_->{Date}\n"; } } __DATA__ |--------------------------------------| Date: today Request: text here text here text here Name: Joe Bloggs Tel: 0123 45677 email: joebloggs@bloggs.com |--------------------------------------| Date: Today Request: text here text here text here Name: John Smith Tel: 0123 45677 email: johnsmith@smith.com |--------------------------------------|