http://qs321.pair.com?node_id=528767

uksza has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I need sometimes in my litte scripts date/time in nice format. I can use (on Linux machines):
my $date = `date +%Y-%m-%d_%H:%M`; chomp $data;
or
my ( $ss, $mm, $hh, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(); my $data = sprintf( "%d-%02d-%02d %02d:%02d", ( $year += 1900, $mon += 1, $mday, $hh, $mm ) );
or
use POSIX 'strftime'; my $date = strftime '%x %X.', localtime;
First is little and nice, but use external program.
Second pure Perl, but a little to long...
Third is almost OK, but is it good idea to use POSIX in 20 lines scripts?
In QandASection: dates and times I can't found nothing else

How do you do this in your's programs?

greetz, Uksza

Yes, smart people know that fat arrow autoquotes the left argument. But why should you require your code to be maintained by smart people?
Randal L. Schwartz, Perl hacker