#!/usr/bin/perl use Getopt::Std; use Jcode; getopts("f:"); $jconv = new Jcode; open FILE, "$opt_f" or die "cannot open $opt_f"; while (){ if ($switch == 0 ){ # ignore if (/From:(.*)/ ){ $from = $1; print "\n\n===========================================\n"; $from =~ s/=([0-9A-Fa-f][0-9A-Fa-f])/pack("H2", $1 )/eg; print "From:$from\n"; }elsif( /To:(.*)/){ print "To:$1\n"; }elsif( /Subject:=?shift-jis?B?(.*)?=/ ){ print "Subject:" . $jconv->set($1)->mime_decode->sjis . "\n"; }elsif (/Content-Transfer-Encoding/){ $switch = 1 } next; }elsif($switch == 1 ){ if ( /END:VBODY/ ){ $switch = 0; next; } } chomp; chop if ( /=$/ ); s/=([0-9A-Fa-f][0-9A-Fa-f])/pack("H2", $1 )/eg; print; }