use POSIX 'strftime'; # ... say POSIX::strftime('%a, %d %b %Y %T %z', localtime);

Now forgive me if that's just a result of a copy-and-paste on your part but it might just be that there's some misconception about the first line. As written it imports strftime() from the POSIX module into the enclosing scope (your script). This means that the function can then be called without prefixing it with the full module name as you have done. To see an already imported function called with the full module prefix looks wrong, even though it works. To my eyes it's like incorrect/inconsistent indentation but YMMV.

Either import it and use the short form:

use POSIX 'strftime'; # ... say strftime('%a, %d %b %Y %T %z', localtime);

Or don't import it at all:

use POSIX (); # ... say POSIX::strftime('%a, %d %b %Y %T %z', localtime);

See also the CAVEATS section of the docs which points out that POSIX exports almost everything by default so you can even do:

use POSIX; # ... say strftime('%a, %d %b %Y %T %z', localtime);

but that is absolutely not recommended in the case of POSIX.

HTH.

(Edited to specify that the final example is bad for POSIX because it exports tons of symbols - the approach is generally OK for other, better-behaved modules)


In reply to Re^2: date and time using localtime by hippo
in thread date and time using localtime by sreek3502

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.