Jeff D works on a team that develops applications on just about any platform under the sun. One day, a perl-based application they developed for a client just stopped working. This was actually a pretty common occurrence; the perl programmer who built the app would just jump in, do his magic, and voilà, it'd be fixed. But this time, the perl guy was unavailable, leaving Jeff (who had no perl experience whatsoever) to fix the problem.
Jeff learned that the problem was caused by $ftpdate, or, more specifically, $ftpdate not having yesterday's date being stored in it. There was definitely a bug in the code generating $ftpdate, but Jeff had no idea what it was. He was able to use Google to find out what the built-in modules were for date manipulation. This was apparently beyond the resident "perl expert" who believed in using the operating system's /bin/date instead ...
$datestring = `/bin/date +%Y%m%d`; if ($datestring =~ /0101$/) { $it_is_the_first_of_the_year = 1; $current_year = `/bin/date +%Y`; chomp $current_year; $last_year = $current_year - 1; $ftpdate = "${last_year}0101"; } elsif ($datestring =~ /01$/) { $it_is_the_first_of_the_month = 1; $monthofyear = `/bin/date +%m`; chomp $monthofyear; $monthofyear = $monthofyear - 1; # Here are our thirty-day months if (($monthofyear == "04") || ($monthofyear == "06") || ($monthofyear == "09") || ($monthofyear == "11")) { $day = 30; # Our single 28-day month } elsif ($monthofyear == "02") { $day = 28; # Fall through as a 31-day month } else { $day = 31; } } if ($it_is_the_first_of_the_month) { $year = `/bin/date +%Y`; chomp $year; $ftpdate = "${year}${monthofyear}${day}"; } elsif ($it_is_the_first_of_the_year == 0) { chomp $datestring; $ftpdate = $datestring - 1; }