Code examples from 'Internet Forensics'
Chapter 9 (People and Places)

Example 9-1: convert_quoted_printable.pl
#!/usr/bin/perl -w
# Example 9-1: convert_quoted_printable.pl

# Excerpted from 'Internet Forensics' by Robert Jones
# Published 2005 by O'Reilly Media (ISBN 0-596-10006-X)

if(@ARGV > 1) {
   die "Usage: $0 <mail file>\n";
} elsif(@ARGV == 0) {
   $ARGV[0] = '-';
}

my $lastline = '';

open INPUT, "< $ARGV[0]" or die "$0: Unable to open file $ARGV[0]\n";
while(<INPUT>) {
    my $line = $_;
    $line =~ s/\=([0-9A-Fa-f][0-9A-Fa-f])/chr hex $1/ge;
    if($line =~ /\=$/) {
       chomp $line;
       $line =~ s/\=$//;
       $lastline .= $line;
    } else {
       $line = $lastline . $line;
       print $line;
       $lastline = '';
    }
}
close INPUT;