Hi Badri,
Soundararajan, Badrinarayanan wrote:
> Hi,
> This is the code i originally had and this is what i replaced with.
> both are hogging a lot of time.
>
(code snipped)
Here is my attempt using DateTime :-)
use strict;
use warnings;
use DateTime;
use DateTime::Format::Strptime;
my $format = new DateTime::Format::Strptime( pattern => '%D' );
my @array = map { $format->parse_datetime($_) } (<DATA>);
my $dur = $array[0]->delta_md( $array[1] );
print $dur->in_units('months');
__DATA__
01/21/04
05/13/05
NOTE:
See the How Date Math is Done section of the DateTime.pm documentation
for more details.
I hope this helps
Ron