Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Re: help on getting date

by arturo (Vicar)
on Jun 02, 2003 at 18:05 UTC ( #262443=note: print w/ replies, xml ) Need Help??


in reply to Re: help on getting date
in thread help on getting date

First off I want to emphasize that you're right on all the really important points. The nit I will pick is that "need" is kind of a strong word, given that there's a pretty simple way to convert MM-DD-YYYY to YYYY-MM-DD format, even if it's not widely capable like a Date::* module:

# assumes you have 0-padded dates, but if you don't you can change # the \d\d's to \d\d?'s , and do an appropriate sprintf. my @ymd = map { my ($m, $d, $y) = $_ =~ /(\d\d)-(\d\d)-(\d{4})/; "$y- +$m-$d"; } @dmy;

HTH

If not P, what? Q maybe?
"Sidney Morgenbesser"


Comment on Re: Re: help on getting date
Download Code
Re: Re: Re: help on getting date
by boo_radley (Parson) on Jun 02, 2003 at 19:33 UTC

    why bother with the temporary variables, especially inside map? Heck, you'd also screen out a small subset of invalid data.
    print  map {$_ =~ /(\d\d)-(\d\d)-(\d{4})/ && "$3-$1-$2"; } ("01-02-1999");
    of course, using this kind of code, you'd need to make sure that your dataset's valid -- you won't get Date::Manip's heavy duty "Am I valid datetime or not" routines.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://262443]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (12)
As of 2014-07-22 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (124 votes), past polls