in reply to Re: Re: Date Regex
in thread Date Regex

In my experience (which is not the sum totality of existence), once you start down a way of doing things, you tend to stick with it, and you always have to do more complicated things. Just as you said, Date::* is better for more complex things. Right now, you're right in that a regex would probably be just fine. If this wasn't code for production use, I would probably also use a regex.

However, in my advice, I always assume (unless otherwise noted) that the poster is asking about code that will eventually end up in production use. Unless you're someone like japhy, Abilgail-II, or tye, I would not recommend using regexes to parse irregular formats in production code. (And, yes, dates are irregular formats, regardless of whether you know where it's coming from. You might know today, but you don't know about tomorrow.)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re3: Date Regex
by greenFox (Vicar) on Mar 27, 2003 at 09:33 UTC
    There is something worrying about what you are saying... all incoming data is an "irregular format", if you get something that you don't expect then your program should be robust enough to handle that in a way that is appropriate to the application. If the incoming data suddenly changes to using Klingon time then things will break how ever you parse it.

    --
    Life is a tale told by an idiot -- full of sound and fury, signifying nothing. William Shakespeare, Macbeth

      If you're using Date::Calc and it handles Klingon time, then your application will now be able to parse and work with Klingon time, without you having to do a thing. That's the point behind using modules. It's code that does more than you ever hoped without you having to lift a finger in support.

      ------
      We are the carpenters and bricklayers of the Information Age.

      Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.