mhonarc-users

Re: Splitting mail by month

1997-11-20 18:43:36
: On Thu, 20 Nov 1997, Laura I. Tapia wrote:
: 
: > I do have a way of splitting mail by month, but it is quite
: > a tedious process. Not hard, just a bit annoying.
: > I don't have the steps to give you yet, let me think the process
: > through enough to write it down...
: 
: Actually, I think I've got the problem solved. I wrote up the following
: perl script called sortmail.pl and used it as such:
: 
: formail -s sortmail.pl < MAILFILE
: 
: I had to hard code in the dates, but with just a little bit more work it
: could easily figure out what file to put it in by what it saw on the From
: line instead of having to explicitly check for each month.


Date::Parse might be useful here

use Date::Parse;
# Grab the date string out of the mail header using formail?
($ss,$mm,$hh,$day,$month,$year,$zone) = strptime($date);
# use these to pick a file to write out to, e.g. pilot.$month$year.ajw

Or something like that, ;-)

Eric

: 
: #!/usr/local/bin/perl
: 
: sub output {
:       foreach (@msgarray) {
:               print FILE "$_\n";
:       }
:       exit;
: }
: 
: while (<STDIN>) {
:       $msg .= $_;
: }
: 
: @msgarray = split(/\n/,$msg);
: 
: if ($msgarray[0] =~ / Jun .*1996/) {
:       open(FILE,">>pilot.0696.ajw");
:       &output;
: }
: if ($msgarray[0] =~ / Jul .*1996/) {
:         open(FILE,">>pilot.0796.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Aug .*1996/) {
:         open(FILE,">>pilot.0896.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Sep .*1996/) {
:         open(FILE,">>pilot.0996.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Oct .*1996/) {
:         open(FILE,">>pilot.1096.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Nov .*1996/) {
:         open(FILE,">>pilot.1196.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Dec .*1996/) {
:         open(FILE,">>pilot.1296.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Jan .*1997/) {
:         open(FILE,">>pilot.0197.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Feb .*1997/) {
:         open(FILE,">>pilot.0297.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Mar .*1997/) {
:         open(FILE,">>pilot.0397.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Apr .*1997/) {
:         open(FILE,">>pilot.0497.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / May .*1997/) {
:         open(FILE,">>pilot.0597.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Jun .*1997/) {
:         open(FILE,">>pilot.0697.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Jul .*1997/) {
:         open(FILE,">>pilot.0797.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Aug .*1997/) {
:         open(FILE,">>pilot.0897.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Sep .*1997/) {
:         open(FILE,">>pilot.0997.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Oct .*1997/) {
:         open(FILE,">>pilot.1097.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Nov .*1997/) {
:         open(FILE,">>pilot.1197.ajw");
:         &output; 
: }
: if ($msgarray[0] =~ / Dec .*1997/) {
:         open(FILE,">>pilot.1297.ajw");
:         &output; 
: }
: print;
: 
: 
: --
: Tracy Reed    http://www.ultraviolet.org   
: "Every artist is a cannibal, every poet is a thief.
:  They all kill their inspiration, and sing about the grief."
: 
--
Eric D. Friedman
friedman(_at_)uci(_dot_)edu

<Prev in Thread] Current Thread [Next in Thread>