-- Mark Van Overbeke Systems Administrator Computing Services 600 East 4th Street University of Minnesota, Morris e-mail: markvo_at_mrs.umn.edu Morris, MN 56267 Phone: 1-320-589-6378 -- Success is the progressive realization of your worthwhile goal or dream! #!/bin/perl -i.vms 'di'; 'ig00'; # # Fixmail - convert VMS mail files to Unix form. # To save a VMS e-mail folder in a usable text file... # inside of VMS MAIL # EXTRACT/ALL/MAIL filename # # N.B.: does in-place editing. # # 04.12.97 modified by U. Siodlaczek to handle also OpenVMS mail # $/ = "\f\nFrom" ; # Break at messages, not lines $frompat1 = '^:\t(\S+)' # sender address . ' +(".+")?' # sender name . ' *(\d+)-(\w{3})-(\d{2}(\d{2}))' # dd-mm-yyyy date . ' +(\d+:\d+:\d+)\.?\d*' # hh:mm:ss.xx time . " *\n" ; $frompat2 = '^:\t(\S+)' # sender address . ' +(".+")?' # sender name . ' *(\d+)-(\w{3})-(\d{2}(\d{2}))' # dd-mm-yyyy date . ' +(\d+:\d+)\.?\d*' # hh:mm:ss.xx time . " *\n" ; while (<>) # Read next message { s|$/$|\n| ; # Drop start of next message if ($. == 1) # First message in input file? { s/^\s*From// ; # Handle missing initial \f\n next if ! /\S/ ; # Handle leading \f\nFrom } $mesg++ ; # Count messages # warn (" ($addr, $name, $day, $mon, $year, $yr, $time) = (/$frompat/) \n"); if (($addr, $name, $day, $mon, $year, $yr, $time) = (/$frompat1/)) { s/^.*\n// ; # drop From: line (($to) = /^To:\t(\S+) */) && s/^.*\n// ; # drop To: line (($cc) = /^CC:\t(.*)/) && s/^.*\n// ; # drop CC: line (($subj) = /^Subj:\t(.*)/) && s/^.*\n// ; # drop Subj: line $name =~ s/^"(.+)"$/$1/ ; # drop quotes $addr =~ s/^IN%"([^"]+)"$/$1/i ; # fix IN% $addr =~ s/^ARPA%"([^"]+)"$/$1/i ; # fix ARPA% $addr =~ s/^JNET%"([^"]+)"$/$1.bitnet/i ; # fix JNET% $addr =~ s/^UUCP%"([^"]+)"$/$1.uucp/i ; # fix UUCP% $addr =~ s/^BITNET%"([^"]+)"$/$1/i ; # fix BITNET% $addr =~ s/(\S+)::(\S+)/$2\_at_$1/ ; # fix VMS hosts $day = sprintf ("%2d", $day) ; # pad date $wkdy = &weekday ($day, $mon, $year) ; print "From \L$addr\E $wkdy \u\L$mon $day $time $year\n" ; print "From: $name <\L$addr\E>\n" if $name ; print "Subject: $subj\n" if $subj ; print "To: \L$to\n" if $to ; print "Date: $wkdy, $day \u\L$mon\E $yr $time\n" ; print "Cc: $cc\n" if $cc ; print ; next ; } if (($addr, $name, $day, $mon, $year, $yr, $time) = (/$frompat2/)) { s/^.*\n// ; # drop From: line (($to) = /^To:\t(\S+) */) && s/^.*\n// ; # drop To: line (($cc) = /^CC:\t(.*)/) && s/^.*\n// ; # drop CC: line (($subj) = /^Subj:\t(.*)/) && s/^.*\n// ; # drop Subj: line $name =~ s/^"(.+)"$/$1/ ; # drop quotes $addr =~ s/^IN%"([^"]+)"$/$1/i ; # fix IN% $addr =~ s/^ARPA%"([^"]+)"$/$1/i ; # fix ARPA% $addr =~ s/^JNET%"([^"]+)"$/$1.bitnet/i ; # fix JNET% $addr =~ s/^UUCP%"([^"]+)"$/$1.uucp/i ; # fix UUCP% $addr =~ s/^BITNET%"([^"]+)"$/$1/i ; # fix BITNET% $addr =~ s/(\S+)::(\S+)/$2\_at_$1/ ; # fix VMS hosts $day = sprintf ("%2d", $day) ; # pad date $wkdy = &weekday ($day, $mon, $year) ; print "From \L$addr\E $wkdy \u\L$mon $day $time $year\n" ; print "From: $name <\L$addr\E>\n" if $name ; print "Subject: $subj\n" if $subj ; print "To: \L$to\n" if $to ; print "Date: $wkdy, $day \u\L$mon\E $yr $time\n" ; print "Cc: $cc\n" if $cc ; print ; next ; } /^(.*)/ && warn ("\nSkipping garbled message \#$mesg:\n\tFrom$1\n") ; } continue { close (ARGV) if (eof) ; # Reset line numbers if multiple files } sub weekday { local ($day, $mon, $year) = _at__ ; %month = ( jan, 0, feb, 1, mar, 2, apr, 3, may, 4, jun, 5, jul, 6, aug, 7, sep, 8, oct, 9, nov, 10, dec, 11 ) ; _at_offset = ( 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 ) ; _at_wkday = ( Mon, Tue, Wed, Thu, Fri, Sat, Sun ) ; $m = $month {"\L$mon"} ; # month number $y = $year - ($year % 4) ; # previous leapyear $leap = $year == $y ; # current leapyear $weekday = 5 ; # for 1/1/2000 $weekday += 5 * ($y - 2000) / 4 ; # for 1/1/$y $weekday += ($year - $y) + !$leap ; # for 1/1/$year $weekday += $offset [$m] + ($leap && ($m > 1)) ; # for $m/1/$year $weekday += $day - 1 ; # for $m/$day/$year $wkday [$weekday % 7] ; } ######################## .00; 'di .nr nl 0-1 .nr % 0 '; __END__Received on Fri Mar 19 1999 - 17:46:17 NZDT
This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:39 NZDT