i'm learning perl by example and couldn't find a simple but fast solution to this.
Email::MIME will handle the decoding for you either for one header or for all of them. Here's a quick demo of both.
#!/usr/bin/env perl use strict; use warnings; use Email::MIME; use Encode; my $raw = <<'EOT'; Subject: =?UTF8?B?5LuO5Y2a5a6i5paH56ug5Lit5p+l5om+5oKo5oSf5YW06Laj55qE5Li7?==?U +TF-8?B?6aKY?= =?UTF8?B?it5p+l5om+5oKo5oSf5YW06Laj55?= To: larry@perl.org From: peteredhair@perlmonks.org Hi Larry! EOT my $email = Email::MIME->new ($raw); # Just one my $subj = $email->header ('Subject'); print "Single header subject is '", encode ("utf-8", $subj), "'\n\n"; # Or all of them my @headers = $email->header_str_pairs (); while (@headers) { my $key = shift @headers; my $val = shift @headers; print "$key: ", encode ("utf-8", $val), "\n"; }
PS. This is essentially hinted at in the FAQ How do I parse a mail header?
In reply to Re: eMail processing for alarmistic
by hippo
in thread eMail processing for alarmistic
by peteredhair
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |