#!/usr/bin/perl
## Quickie script to display mail summary for mbox folders
## troy@zenux.net

############## Sample output: #############
#[troy@dubhe:~] ./bin/ml
#      fd	Total:   0	Unread:   0	      0
#  fryman	Total:  20	Unread:   0	 259084
#    spam	Total:   1	Unread:   1	   5651
#     vox	Total: 393	Unread: 244	1810305
#  zaurus	Total: 210	Unread:  75	1210901
#     zin	Total:  22	Unread:   0	 991368


use strict;
my $HOME	= $ENV{'HOME'};
my $MAILDIR = "${HOME}/mail";

## customize this section
my %dirs=(
	zin  	    => $ENV{'MAIL'},
	fryman		=> "${MAILDIR}/fry",
	vox			=> "${MAILDIR}/vox",
#	deb			=> "${MAILDIR}/deb",
	zaurus		=> "${MAILDIR}/z",
	root		=> "${MAILDIR}/root",
	fd			=> "${MAILDIR}/fd",
	spam		=> "${MAILDIR}/spam",
	);
## That's it.

foreach my $dir (sort keys %dirs) {
	next unless open(M,"<$dirs{$dir}");
	my ($messages,$read)=0;
	while(<M>) {
	        /^From / && ++$messages;
	        /^Status:/ && /R/ && ++$read;
	}
	printf ("%8s\tTotal: %3s\tUnread: %3s\t%7s\n",$dir,$messages,($messages-$read),(stat(M))[7]);
	close M;
}

__END__