Charles K. Clarkson wrote:
[EMAIL PROTECTED] wrote:
Gunnar Hjalmarsson wrote:
Personally I don't know which of all the date related modules
that would fit best, but I'm sure others do. I for one wouldn't
use any module:
my $time = time;
sub mydate {
my $days = (shift or 0);
my ($d, $m, $y) = (localtime($time - $days * 86400))[3..5];
sprintf '%02d.%02d.%02d', $m + 1, $d, $y % 100;
}
print 'Today: ', mydate(), "\n";
print 'Yesterday: ', mydate(1), "\n";
one more thing, shouldn't my $time = time;
be
local $time = time;
even though my is safer and faster, local can be used globally
and called from within any subroutine?
A file scoped my() declared variable can be called from subroutines in
that same file, but if you want to access a variable from loaded
modules etc., it needs to be a (package) global.
I would probably use $^T in place of $time in this sub.
Then I presume that you are usually not running your programs under
mod_perl. ;-)
AFAIK it will always return the time stamp when the script started.
I believe it returns the 'epoch' time at the start of the process,
which under mod_perl does not equal the time of the last program
invocation.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>