Re: Date function



In article <1164750487.485271.239390@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
"K.J. 44" <Holleran.Kevin@xxxxxxxxx> wrote:

Hi,

is there a date function in Perl or do I have to try to find a module?

What i need is to be able to come up with the current date, then
subtract one day, and add that to the file name in the form of:

YYYY-MM-DD-RestOfFileName.txt

The script I have written parses these files and I want to run it every
night after midnight on the previous days file which has the naming
convention above.

I am running ActiveState Perl in a Windows environment.

Thanks.

There are built-in functions and modules, and numerous ones in the CPAN
library. I usually build this kind of thing myself, finding it quicker
than trying to find the right module.

something like:

my( $day, $mon, $yr ) = ( localtime( time - 24*3600) )[3, 4, 5];
$yr += 1900;
$mon += 1;
my $str = sprintf '%4d-%02d-%02d', $yr, $mon, $day;

would give you the prefix string for your filename.

Boyd
.



Relevant Pages

  • Re: Date function
    ... Sharif Islam wrote: ... I am running ActiveState Perl in a Windows environment. ...
    (comp.lang.perl.misc)
  • Re: Date function
    ... Sharif Islam wrote: ... I am running ActiveState Perl in a Windows environment. ...
    (comp.lang.perl.misc)
  • Re: Date function
    ... I am running ActiveState Perl in a Windows environment. ... use strict ...
    (comp.lang.perl.misc)
  • Re: existence and size of client file
    ... built-in functions. ... But since Perl is _not_ running on the client ... while processing an HTTP CGI request, you cannot use Perl (or any other ...
    (comp.lang.perl.misc)
  • Re: Unix commands
    ... Some folks treat Perl like a glorified korn shell, ... Perl has built-in functions for a lot of stuff you ... Why do the Alphabet song and Twinkle, Twinkle Little Star have the same tune? ...
    (comp.lang.perl.misc)