#!/usr/bin/perl # getdate.pl # Written by Jeff Borders # # Perl script that returns # todays or yesterdays date in the # format MMDDYY. #use strict; use warnings; use Getopt::Std; use Date::Calc qw( Today Add_Delta_YMD); our ($opt_y, $opt_h); my ($year,$month,$day,$date); getopts('yh'); # -y will return yesterday's date. # -h will return help. if (defined $opt_y) { ($year,$month,$day) = Add_Delta_YMD(Today (),-2000,0,-1); } elsif ( defined $opt_h ) { print "Usage: $0 for todays date\n"; print "Usage: $0 -y for yesterdays date\n"; exit; } else { ($year,$month,$day) = Add_Delta_YMD(Today (),-2000,0,0); } $date = sprintf("%02d%02d%02d\n",$month,$day,$year); print $date;