in reply to How to parse a scalar variable
Mail::Header may be of interest.
If you want to parse this on your own, try paragraph mode ($/ = '';) and read the first "line" to get all the headers. You can then split on newlines to get the lines and on colon to get header tags and content.
You may need to fiddle with the newline split, but I tried to make it cover the possibilities. The scalar operator isn't really necessary before the diamond read, but it documents intent. The inner map just trims and normalizes whitespace, and may be omitted.my $headers = do { local $/ = ''; scalar <$fh>; }; my %header = map { map { join ' ', split; } split /: /, $_, 2; } split /\r?\n\r?/, $headers;
After Compline,
Zaxo
|
|---|