Other bugs which are passe

After talking about a problem with older versions of Opera, here is a problem with version 5.8.4 of ActivePerl for Windows (but which isn’t present in 5.8.8, so the simple solution is to upgrade):

If you use the POSIX module to print out the day of the week (Friday, Monday, etc) with a code like the one below:

use POSIX;
print POSIX::strftime('%A', localtime());

The Perl interpreter will lock up. If you try to use a formatting string which has more placeholders (for example strftime( "%A, %B %d, %Y", 0, 0, 0, 12, 11, 95, 2 );), it will omit the weekday part. I discovered this by investigating why the emails sent by the SVN commit hook had no date, only to discover that they were missing the weekday, thus creating an invalid date. Below is a quick patch to work around this issue (the proper solution is of course to upgrade to 5.8.8 or 5.10):

my $weekday = (localtime())[3];
$formatted_date = strftime('%a %b %% %X %Y', localtime());
$formatted_date =~ s/%/$weekday/;

Leave a Reply

Your email address will not be published. Required fields are marked *