--- ../../../perfect_maildir/perfect_maildir.pl	Sun Mar  9 11:08:26 2003
+++ perfect_maildir.pl	Sun Jul 11 11:35:24 2004
@@ -17,6 +17,9 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+use POSIX qw(strftime);
+use Date::Parse qw( str2time );
+
 # Get the hostname
 
 my $hostname = `hostname`;
@@ -49,6 +52,7 @@
 my $headers = '';
 my $flags = '';
 my $subject = '';
+my $date = '';
 while (my $line = <STDIN>) {
   # detect end of headers
   last if $line eq "\n";
@@ -60,10 +64,18 @@
   $flags .= $1 if $line =~ /^Status: ([A-Z]+)/;
   $flags .= $1 if $line =~ /^X-Status: ([A-Z]+)/;
   $subject = $1 if $line =~ /^Subject: (.*)$/;
+  $date = $1 if $line =~ /^Date: (.*)$/i;
 }
 
 $num++;
 
+# convert date to timestamp 
+my $tstamp = '';
+if ($date) {
+	$tstamp = str2time($date);
+	#$date 	= strftime("%Y%m%d%H%M.%S", localtime($tstamp));
+}
+
 # open output file
 my $file;
 if ($flags =~ /O/) {
@@ -96,6 +108,9 @@
   print FILE $line;
 }
 close(FILE);
+# change timestamp on file
+utime $tstamp, $tstamp, $file;
+
 goto repeat unless eof(STDIN);
 
 my $elapsed = time - $time;
