mailinfo


[Home] [Dissertação] [Biba] [Linux] [Conjugue] [br.ispell] [axw3] [uplink]

#!/usr/bin/perl
#
# mailinfo, by Ricardo Ueda Karpischek.
#
# put "mailinfo -login >.plan" at your .bash_profile
# put "mailinfo -logout >.plan" at your .bash_logout
#
# obs1. these commands|filenames may not work for you
# obs2. change "Mailbox" below for your personal inbox file
#

open(F,"Mailbox");
$n = 0;
while (<F>) {

    if (/^From:/) {
        ++$n;
        $inheader = 1;
    }
    elsif (($n == 1) && (/^Date:/) && ($inheader == 1)) {
        chop;
        ($df) = /^Date: *(.*)$/;
    }
    elsif (($inheader == 1) && (/^ *$/)) {
        $inheader = 0;
    }
}
close(F);

print "\n$n mails in mailbox\n";
if ($ARGV[0] eq "-login") {
    open(G,"hostname|");
    $hostname = <G>;
    chop($hostname);
    print "seems to be at $hostname\n";
}
else {
    if ($n > 0) {
        print "date of first mail in mailbox: $df\n";
    }
    print "last logout " . (localtime) . "\n";
}
print "the script www.ime.usp.br/~ueda/ldoc/mailinfo generated this info\n";
print "\n---\n<<There are no friends like old friends>> (J.H.Newman)\n---\n";