[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
: Gunnar Hjalmarsson <[EMAIL PROTECTED]> 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?
So can a variable scoped with 'my'. Are you near a
machine you can test this on?
I would probably use $^T in place of $time in this
sub. AFAIK it will always return the time stamp when
the script started.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>