Fernando Freire Baez (Medicare) wrote:
Hello,
I have an script that have to open and read a file all days in the morning.
The script is fine but I have a little doubt about the file name. The file
name is the day before the current day, so, for example: today is 11/14/2002
and the name of the file that the script have to open is 11132002.txt (the
day before the current day). I don't know if exists any function or module
that I can use to substract 1 day from the current day and the result are
the name of the file that the script have to proccess. Please let me know
any trick or module. Thanks in advance as always.
Here's two ways:
use strict;
my @t = localtime;
my $file = sprintf "%02u%02u%04u.txt", $t[4]+1, $t[3]-1, $t[5]+1900;
print $file, "\n";
__END__
# or
use strict;
use POSIX;
my @t = localtime; $t[3]--;
my $file = strftime "%m%d%Y.txt", @t;
print $file, "\n";
__END__
--
,-/- __ _ _ $Bill Luebkert ICQ=162126130
(_/ / ) // // DBE Collectibles Mailto:dbe@;todbe.com
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs