#!/usr/bin/perl -w use strict; use POSIX; use Getopt::Long; use Date::Manip; use constant SECONDS_IN_MINUTE => 60; use constant MINUTES_IN_HOUR => 60; use constant HOURS_IN_DAY => 24; use constant DAYS_IN_WEEK => 7; # set some defaults my $sdate = time; my $weekseconds = SECONDS_IN_MINUTE * MINUTES_IN_HOUR * HOURS_IN_DAY * DAYS_IN_WEEK; my $edate = $sdate + ( $weekseconds ); # which can be overridden by your cmd line options # I didn't add anything for the -brtype etc GetOptions( 'sdate:s' => sub { $sdate = &process_date($_[1])}, 'edate:s' => sub { $edate = &process_date($_[1])}); printf("start time is %s, end time is %s\n", strftime("%d %b %Y %H:%M:%S", localtime($sdate)), strftime("%d %b %Y %H:%M:%S", localtime($edate))); sub process_date { my $d = shift; my $date = &ParseDate($d); if( ! $date ) { die("cannot determine date from $d\n"); } return &UnixDate($date, "%s"); }