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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |