#!/usr/bin/perl # http://www.cs.albany.edu/~mosh # SYNOPSIS: clean mail files. $/ = undef; # Multi-line patterns/m $_ = <>; # Read in whole file! # Apply these only to the header? s/\n{3,}/\n\n/g; # n blank lines => 2 blanks lines. s/[ \t]+\n/\n/g; # \s eats up \n, since $/ is undef above. 1 while s/^(Received:\s[^\n]+\n)(\s+[^\n]+\n)*//mg; 1 while s/^(Message-Id:\s[^\n]+\n)//mg; print;