Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: tlug: archiving mail
- To: tlug@example.com
- Subject: Re: tlug: archiving mail
- From: simon@example.com (Simon Cozens)
- Date: 27 Jun 2000 14:16:53 GMT
- Delivered-To: simon-outgoing@example.com
- Organization: Earth.li Origins
- References: <lists.tlug/20000627213342.B9316@example.com>
- Reply-To: tlug@example.com
- Sender: owner-tlug
- User-Agent: slrn/0.9.5.3 (UNIX)
John Seebach (lists.tlug): >Anyone know of a program that already does this? This is a start; I'll polish it up later so you can change the format of the archive's name, and specify the required age on the command line. However, I thought it would be interesting to do it "pedantically correct" rather than quick-and-dirty Perl: #!/usr/bin/perl -w use Mail::Internet; use Mail::Header; use Date::Calc qw(Delta_Days Decode_Date_EU Today); use Fcntl; use Mail::Util qw(read_mbox); use strict; my $age = 30; # Days process(@example.com); sub newname { my ($file, $age) = @example.com; return "$file-old"; } sub process { for my $file (@example.com) { next unless -f $file; my @example.com = read_mbox($file); my $newname=newname($file, $age); unless (open ARCHIVE, ">".$newname) { warn "Couldn't write on file $newname: $!, skipping $file\n"; next; } unless (rename $file, "$file.bak") { warn "Couldn't rename $file: $!, skipping\n"; next; } unless (open ORIG, ">".$file)) { warn "Couldn't write on file $file: $!, skipping\n"; next; } unless (flock(ORIG, LOCK_EX)) { warn "Couldn't lock box $file: $!, skipping\n"; next; } foreach (@example.com) { my $date = Mail::Header->new($_)->get("Date"); $date =~ s/\d\d:\d\d.*$//; my $delta = Delta_Days(Decode_Date_EU($date),Today()); if ($delta > $age) { print ARCHIVE @example.com } else {print ORIG @example.com} } flock(ORIG, LOCK_UN); close ORIG; close ARCHIVE; unlink "$file.bak" or warn "Trouble removing $file.bak: $!\n"; } } -- And tomorrow will be like today, only more so. -- Isaiah 56:12, New Standard Version ----------------------------------------------------------------------- Next Technical Meeting: July 8 (Sat) 13:30 Place: LinuxProbe Hall Next Nomikai meeting: August 18 (Fri) 19:00 Place: TBD ----------------------------------------------------------------------- more info: http://www.tlug.gr.jp Sponsor: Global Online Japan
- Follow-Ups:
- Re: tlug: archiving mail
- From: John Seebach <jseebach@example.com>
Home | Main Index | Thread Index
- Prev by Date: tlug: debian users who use mutt
- Next by Date: Re: tlug: Mozilla, uh, M15
- Prev by thread: Re: tlug: archiving mail
- Next by thread: Re: tlug: archiving mail
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links