obrienmd has asked for the wisdom of the Perl Monks concerning the following question:

I have a variable which is a time range:
ex: 7:00 AM - 9:15 AM
ex: 12:00 AM - 2:00 PM

As you can see, I can't just grab a # of charachters. I'd like to use some perl code and end up with:
example variable = 7:00 AM - 9:15 PM
example product variable 1 = 070000
example product variable 2 = 211500

Thanks!
  • Comment on How to split an inconsistent time range into two consistent times?

Replies are listed 'Best First'.
Re: How to split an inconsistent time range into two consistent times?
by GrandFather (Saint) on Dec 02, 2009 at 06:28 UTC

    What have you tried? What do you need to do after extracting the values? Your question looks like it is very tightly focused on one small part of a problem.

    A regular expression (see perlre and perlretut) could be part of the answer, but if you intend to manipulate the times in some fashion after extracting them you may find one of the many Date/Time modules (such as Date::Manip) are worth investigating.


    True laziness is hard work