in reply to Scanning a text file

This might not work as I expect it to, but . . .

local $/ = '%%%'; # Assume 'FH' is input file, opened elswhere my @records; while(my $line = <FH>) { $line =~ s/%%%//; # Remove any beginning or trailing whitespace # NOTE: Using \A and \z instead of ^ and $ is critical $line =~ s/\A \s* (.*?) \s* \z/$1/x; my %rec = split /[:\n]/, $line; push @records, \%rec; }

@records should now hold an array-of-hashes containing the name/value pairs of your data. This may fail for some data, such as if a ':' appears anywhere besides splitting the name/value pairs in the file. It depends on the fact that the flattend list comming out of split can be coerced into a hash.

----
: () { :|:& };:

Note: All code is untested, unless otherwise stated