in reply to Regex Epiphany

Aren't you supposed to keep that "AM"/"PM" intact?
s/(?<=[AP]M).+//;

Replies are listed 'Best First'.
Re^2: Regexp Epiphany
by Sigmund (Pilgrim) on Aug 22, 2004 at 16:38 UTC
    oh, it actually doesn't matter.
    I can safely remove AM or PM and it all works ok!

      How can it? You lose information. That strings contains nothing else that would indicate whether the times are AM or PM. Date::Manip is probably assuming 24-hour-time, effectively assuming AM for all times.

      Did you actually test your assumption or are you simply programming by coincidence?

      $ perl -MDate::Manip -le'print UnixDate "Wed, 28 Jul 2004 9:12 PM", "% +s"' 1091041920 $ perl -MDate::Manip -le'print UnixDate "Wed, 28 Jul 2004 9:12", "%s"' 1090998720

      You didn't notice that, because you're not asking for the time, only for the date. Are you sure you will never want to see the time, in a future change to the script? Will you remember this idiosyncracy of your solution at the time? You should at least document this issue in your script; the better approach would of course be to either strip the entire time out of the string completely (Date::Manip will assume 12AM sharp) or not to destroy this information in the first place.

      Makeshifts last the longest.

        but i don't mind at all...
        my files will be like this:

        sender040822.html

        and the date isn't an important issue.