in reply to potential date and time issues / code cleanup
There's the Date::Calc CPAN module:
use warnings; use strict; use Date::Calc::Object; my $date = Date::Calc->today - 1; [download]
Which will get you yesterday's date in a pretty clean way.