[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Real World Perl



At Thu, 22 Mar 2001 03:44:07 -0500 (EST), Dave Cross <dave@dave.org.uk> wrote:
> At Wed, 21 Mar 2001 23:34:38 -0800, "Derek J. Balling" <dredd@megacity.org> wrote:
> > At 9:57 PM -0800 3/21/01, Vicki Brown wrote:
> > >sub GetToday2 {
> > >     my (undef,undef,undef,$mday,$mon,$year) = localtime(time);
> > >
> > >     sprintf("%4d%02d%02d", $year + 1900, $mon+1, $mday);
> > >
> > >}
> > 
> > why not do:
> > 
> > my ($mday,$mon,$year) = (localtime(time))[3..5];
> 
> a) It's a nasty, non-standard way of ordering dates.
> 
> b) It doesn't pad single digits with preceding zeroes.
> 
> Mind you, the original _can_ be improved:
> 
> my ($mday, $mon, $year) = (localtime)[3 ..5];
> sprintf("%4d%02d%02d", $year + 1900, ++$mon, $mday);

Hmm... On reading this thread, it looks to me like I misparsed Derek's
email and ending up rebuking him for making the same suggestion that
I ended up making.

Sorry for any confusion caused and especially sorry to Derek for 
implying that he didn't know what he was talking about.

I'll stop posting in the morning before having at least two cups of 
coffee :(

> On a similar subject, if you haven't already done so it's _well_ worth
> checking out the new Date-MMDDYY module that was recently uploaded to
> the CPAN.

This is _still_ a good idea tho :)

Dave...

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe