Re: using perl to print yesterday's date, but with formatting options ?



Gunnar Hjalmarsson wrote:
Tom Van Overbeke wrote:

I need a way to use yesterday's date in a variable. The tricks with 'date' don't work on my system, but perl does.

so i've got:
 perl -le 'print scalar localtime time - 86400'  which outputs:
Sun Oct 30 17:56:52 2005

But the format I need is:  30.10.05

Any ideas on how to add this to the above piece of code ?

Capture the date string in a variable and use the tr/// operator.

Sorry, didn't read the question carefully enough.

Either you can get the date components by evaluating localtime() in list context

    perldoc -f localtime

and create the date string you want 'by hand', or you can use one of the many date modules.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.



Relevant Pages

  • Re: Docs comprehensibility
    ... who started his programming 'career' a few years ago by modifying Matt ... to fix the Perl documentation. ... >> feel confident enough. ... Gunnar Hjalmarsson ...
    (comp.lang.perl.misc)
  • Re: redirect without meta
    ... Tad McClellan wrote: ... it was a CGI problem rather than a Perl ... system interaction, emails, database communication etc. ... Gunnar Hjalmarsson ...
    (comp.lang.perl.misc)
  • Re: redirect without meta
    ... >> program written in Perl. ... >> system interaction, emails, database communication etc. politely ... There was nothing wrong with your response; ... Gunnar Hjalmarsson ...
    (comp.lang.perl.misc)
  • Re: clpannounce problem
    ... Your posting for comp.lang.perl.announce has been received and queued. ... moderated group for announcements of new releases of perl ... Please do not include the *entire* documentation of your item. ... Gunnar Hjalmarsson ...
    (comp.lang.perl.misc)
  • Re: Why does Perl use more resource than Php?
    ... A Perl app that means a large number ... >> require less CPU for a similar app, so the language may well be ... Gunnar Hjalmarsson ...
    (comp.lang.perl.misc)