#!/usr/bin/perl -w # Convert a majordomo digest to a mbox folder. rough and ready. # Waider August 2000 my $header_done = 0; my $lines = 0; my $inmsg = 0; while (<>) { # Strip off header $header_done or next unless /^-+$/; $header_done = 1; if ( /^-+$/ ) { $lines ++; # Digest has a line of dashes before the actual digest. next if $lines < 2; print "\n" if $lines > 2; # extra inter-message blanks $inmsg = 0; next; # don't leave dashed lines in place. } # Note that we punt on getting the day correct if it's not present. !$inmsg and /^Date:\s*(([A-Z][a-z][a-z]),)?\s*(\d{1,2})\s*([A-Z][a-z][a-z])\s*(\d{2,4})\s*(\d{1,2}):(\d{1,2})(:(\d{1,2}))?/ and printf( "From VM %s %s %02d %02d:%02d:%02d %04d\n", $2||"Mon", $4, $3, $6, $7, $9||"00", (( $5 > 10 && $5 < 100 ) ? 1900 + $5 : $5 )); /^Date:/ and $inmsg = 1; $inmsg && s/^- -/-/; # unescape dashes s/^From /^>From/; # sigh print if $inmsg; }