http://qs1969.pair.com?node_id=584212

japhy has asked for the wisdom of the Perl Monks concerning the following question:

A co-worker of mine has 600,000+ .EML files which contain some UTF-8 encoded text. Here's a sample:
To: =?utf-8?B?Q2FuY2VsbGF0aW9uIDxDYW5jZWxsYXRpb25Abm9ydmVyZ2VuY2UuY29t +Pg==?= CC: =?utf-8?B?VGltIEhpbGtlIChSVlApIDx0aW0uaGlsa2VAbm9ydmVyZ2VuY2UuY29t +PiwgQmVybmFyZCBDb3lsZSBNVlAgb2 YgREMgPGJlcm5hcmQuY295bGVAbm9ydmVyZ2VuY2UuY29tPiwgRGF2aWQgQnV0bGVyIChB +VlApIDxkYXZpZC5idXRsZXJAbm9ydm VyZ2VuY2UuY29tPiwgVGltb3RoeSBDYXNleSA8dGltb3RoeS5jYXNleUBub3J2ZXJnZW5j +ZS5jb20+?= Microsoft Mail Internet Headers Version 2.0 Received: from SERVER.REMOVED ([IP.RE.MO.VED]) by SERVER.REMOVED with Microsoft SMTPSVC(5.0.2195.6713); Thu, 24 Jun 2004 13:47:45 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 content-class: urn:content-classes:message MIME-Version: 1.0 Subject: SOME EMAIL SUBJECT Date: Thu, 24 Jun 2004 13:47:44 -0400 Message-ID: <F237EF3B2E3F5E47BAA4F33B79DB0AB502764A95@SERVER.REMOVED> X-MS-Has-Attach: X-MS-TNEF-Correlator: <F237EF3B2E3F5E47BAA4F33B79DB0AB502764A95@SERVER +.REMOVED> Thread-Topic: SOME THREAD TOPIC Thread-Index: AcRaE1qu8p4j/zoYQ4WJdDsPJbcodg== From: "NAME REMOVED" <NAME.REMOVED@EMAIL.REMOVED Return-Path: NAME.REMOVED@EMAIL.REMOVED
He'd like to decode the To: and Cc: lines. What tools are necessary to do this?
Update: Upon examining MIME::Parser, I've tracked down the necessary code in MIME::Words. My solution is:
#!/usr/bin/perl use MIME::Words 'decode_mimewords'; use strict; use warnings; my @files = @ARGV; for my $file (@files) { local @ARGV = ($file); local $^I = ".bak"; local $/; print scalar decode_mimewords($_) while <>; }

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart