#!/usr/local/bin/perl -w0777 use strict; ## Scott Wiersdorf ## Created: Thu Apr 8 22:58:49 MDT 2004 ## $Id: mail_newer,v 1.1 2005/08/15 18:25:30 scott Exp $ ## print mail message if it's newer than $days ## ## usage: cat message | mail_newer ## or : mail_newer < message ## multiple messages: formail -s mail_newer < mbox ## ## where is the number of days use Time::Local; my($days,$msg) = (shift, <>); my($date) = $msg =~ /^From \S+\s+(.+)$/m; $date =~ s/ / /g; do { print $msg; exit } unless $date; my %m = (Jan=>0, Feb=>1, Mar=>2, Apr=>3, May=>4, Jun=>5, Jul=>6, Aug=>7, Sep=>8, Oct=>9, Nov=>10, Dec=>11); my @d = split /[: ]/, $date; print $msg if timelocal($d[5],$d[4],$d[3],$d[2],$m{$d[1]},$d[6]-1900) >= time-($days*24*60*60);