#!/usr/bin/perl use Date::Manip; use Getopt::Long; my ($from_text, $till_text); GetOptions( from => \$from, till => \$till ); my $from_date = ParseDate($from_text); unless ($from_date) { die "Invalid From date\n"; } my $till_date = ParseDate($till_text); unless ($till_date) { die "Invalid till date\n"; } unless (Date_Cmp($from_date,$till_date) > 0) { die "Horribly\n"; } while(<>) { ... read the date ... if (Date_Cmp($date,$from_date) >= 0 and Date_Cmp($date,$till_date) < 0) { ... here we go ... } }