Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Fetching date

by ysth (Canon)
on Jan 21, 2004 at 16:05 UTC ( #322919=note: print w/replies, xml ) Need Help??


in reply to Fetching date

Other than the missing )/, looks like it.

Do you know for sure that the day-of-month will always be given with 2 digits, and not as e.g. "Feb 1"?

Replies are listed 'Best First'.
Re: Re: Fetching date
by Anonymous Monk on Jan 21, 2004 at 17:19 UTC
    thanks all, but it could also be: Feb 1 00:41 So I could use all your examples for the above also?
      Anonymous Monk,
      You could just make the \d greedy and say \d+ but that runs the risk of mistaken garbage for treasure.
      my ($mon, $day, $hour, $min) = $date =~ /(\w+)\s(\d\d?)\s(\d\d):(\d\d) +/;
      The above should be closer to what you want, but you should keep some things in mind. If you know that the month abbreviation will always be 3 letters long then say so. When the day is 1 instead of 12 does the number of spaces between the hour change in order to get the fields to line up (perhaps in a log)?
      my ($mon, $day, $hour, $min) = $date =~ /(\w{3})\s+(\d\d?)\s+(\d\d):(\ +d\d)/;
      Cheers - L~R

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2020-08-13 18:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (74 votes). Check out past polls.

    Notices?