#! /usr/bin/perl # put into the public domain by Russell Nelson # NO GUARANTEE AT ALL; support is available for a fee from the author. # # Copies all the mail in STDIN into their maildir. # version 0.00 - first release to the public. use Date::Manip; $dest = "new"; # pre-existing mail needs to go into cur. sub finish_file { if ($fn) { close(OUT); rename("tmp/$fn","$dest/$fn"); utime($secs, $secs, "$dest/$fn"); } } ($uid,$gid) = (stat("."))[4,5]; while(<>) { if (/^From .*? (.*)$/) { &finish_file; @date = &UnixDate(&ParseDate($1),qw/%m %d %Y %H %M %S/); $secs = &Date_SecsSince1970(@date); $secs++ if $secs == $oldsecs; $oldsecs == $secs; $fn = "$secs.$$.mbox"; open(OUT, ">tmp/$fn") || die("fatal: unable to create new message");; chown ($uid,$gid,"tmp/$fn"); next; } s/^>From /From /; print OUT || die("fatal: unable to write to new message"); } &finish_file; .