date difference script
-
Hi, I am trying to create a perl date difference script. I would like to put the date2 from a file and put it into an array. Then find the difference between that day and today. Here is what i got (it dont work). Please help. #!/usr/bin/perl # date calculator use Date::Calc qw(Delta_Days check_date); open (DATEFILE, "date.txt")|| die "couldn't open the file!"; @date2 = ; close DATAFILE; open (TODAYFILE, "today.txt") || die "couldn't open the file"; @today = ; print @today; print "\n" ; print @date2; print "\n"; $difference = Delta_Days(@today, @date2); print "There are $difference days before password expires\n"; close TODAYFILE;
-
Hi, I am trying to create a perl date difference script. I would like to put the date2 from a file and put it into an array. Then find the difference between that day and today. Here is what i got (it dont work). Please help. #!/usr/bin/perl # date calculator use Date::Calc qw(Delta_Days check_date); open (DATEFILE, "date.txt")|| die "couldn't open the file!"; @date2 = ; close DATAFILE; open (TODAYFILE, "today.txt") || die "couldn't open the file"; @today = ; print @today; print "\n" ; print @date2; print "\n"; $difference = Delta_Days(@today, @date2); print "There are $difference days before password expires\n"; close TODAYFILE;
-
Hi, I am trying to create a perl date difference script. I would like to put the date2 from a file and put it into an array. Then find the difference between that day and today. Here is what i got (it dont work). Please help. #!/usr/bin/perl # date calculator use Date::Calc qw(Delta_Days check_date); open (DATEFILE, "date.txt")|| die "couldn't open the file!"; @date2 = ; close DATAFILE; open (TODAYFILE, "today.txt") || die "couldn't open the file"; @today = ; print @today; print "\n" ; print @date2; print "\n"; $difference = Delta_Days(@today, @date2); print "There are $difference days before password expires\n"; close TODAYFILE;
This should work #!/usr/bin/perl # date calculator use Date::Calc qw(Delta_Days check_date); open (DATEFILE, "date.txt")|| die "couldn't open the file!"; @date2=<DATEFILE>; close DATEFILE; open (TODAYFILE, "today.txt") || die "couldn't open the file"; @today; @today=<TODAYFILE>; print @today; print "\n"; print @date2; print "\n"; $difference = Delta_Days(@today, @date2); print "There are $difference days before password expires\n"; close TODAYFILE; date.txt 2010 01 20 today.txt 2010 01 15
-
This should work #!/usr/bin/perl # date calculator use Date::Calc qw(Delta_Days check_date); open (DATEFILE, "date.txt")|| die "couldn't open the file!"; @date2=<DATEFILE>; close DATEFILE; open (TODAYFILE, "today.txt") || die "couldn't open the file"; @today; @today=<TODAYFILE>; print @today; print "\n"; print @date2; print "\n"; $difference = Delta_Days(@today, @date2); print "There are $difference days before password expires\n"; close TODAYFILE; date.txt 2010 01 20 today.txt 2010 01 15
Thanks that works great. Here is what i came up with. #!/usr/bin/perl use Date::Calc qw(Delta_Days); use Time::Piece; ($sec, $min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); open (MYDATA, "data.txt") or die ("Error: cannot open file 'ARGV[0]'\n"); my @lines1 = <MYDATA>; # chomp @lines1; my $t = Time::Piece->strptime("@lines1", "%b %d,%Y"); $year1 = $year + 1900; $mon1 = $mon + 1; $mday1 = $mday; $year2 = ( $t->strftime("%Y")); $mon2 = ( $t->strftime("%m")); $mday2 = ( $t->strftime("%d")); $difference = Delta_Days($year1, $mon1, $mday , $year2, $mon2, $mday2); print "There were $difference days between Nat and Bree\n"; print "email user\n" if $difference <= 15; data.txt Jan 24, 2010