Ran into an interesting gotcha between Perl on Linux and Perl on Windows. See this example code:<br>$ cat -n ./<a href="http://d0039.pl">d0039.pl</a><br> 1 #!perl<br> 2 use strict;<br> 3 use POSIX;<br> 4 my $epoc_sec = 1296482400;<br>
5 printf ("%s\n", strftime("%A, %B %e %Y at %l:%M%p", localtime($epoc_sec)));<br> 6 my $TT=localtime($epoc_sec);<br> 7 print qq{$TT \n};<div><br>On my Linux system:<br>$ perl ./<a href="http://d0039.pl">d0039.pl</a><br>
Monday, January 31 2011 at 8:00AM<br>Mon Jan 31 08:00:00 2011</div><div><br>But when run from my Windows box (Win 7, 64bit) using ActiveState:<br>C:\temp>perl <a href="http://d0039.pl">d0039.pl</a><br>%A, %B %e %Y at %l:%M%p<br>
Mon Jan 31 08:00:00 2011</div><div><br>After a bit of Googling, I found this section from the POSIX documentation:<br><br><a href="http://perldoc.perl.org/POSIX.html"></a></div><div><a href="http://perldoc.perl.org/POSIX.html">http://perldoc.perl.org/POSIX.html</a><br>
<blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; ">
If you want your code to be portable, your format (fmt ) argument should use only the conversion specifiers defined by the ANSI C standard (C89, to play safe). These are aAbBcdHIjmMpSUwWxXyYZ% . But even then, the results of some of the conversion specifiers are non-portable. For example, the specifiers aAbBcpZchange according to the locale settings of the user, and both how to set locales (the locale names) and what output to expect are non-standard. The specifier c changes according to the timezone settings of the user and the timezone computation rules of the operating system. The Z specifier is notoriously unportable since the names of timezones are non-standard. Sticking to the numeric specifiers is the safest route.</blockquote>
<br>What I don't get is why ALL of my formatting code entries don't seem to be accepted in the strftime() call...</div><div><br>DanL<br>--<br>***************** ************* *********** ******* ***** *** **<br>"Quis custodiet ipsos custodes?"<br>
(Who can watch the watchmen?)<br> -- from the Satires of Juvenal<br>"I do not fear computers, I fear the lack of them."<br> -- Isaac Asimov (Author)<br>** *** ***** ******* *********** ************* *****************<br>
</div>