Code:
#! /usr/bin/perl -w
use strict;
use POSIX 'strftime';
my $file1 = "05-Apr-2012 13:42:32";
my $file2 = "04-Apr-2012 12:42:41";
my $diff_hrs = ((parse_date ($file1) - parse_date ($file2)) / 3600);
print "$diff_hrs\n";
sub parse_date {
my $t = shift;
my %mnths = ( "Jan" => "01", "Feb" => "02", "Mar" => "03", "Apr" => "04", "May" => "05", "Jun" => "06",
"Jul" => "07", "Aug" => "08", "Sep" => "09", "Oct" => "10", "Nov" => "11", "Dec" => "12" );
my $dt = substr ($t, 0, 2);
my $mt = substr ($t, 3, 3);
my $yr = substr ($t, 7, 4) - 1900;
my $hr = substr ($t, 12, 2);
my $mn = substr ($t, 15, 2);
my $sc = substr ($t, 18, 2);
$mt = $mnths{"$mt"} - 1;
return strftime ("%s", $sc, $mn, $hr, $dt, $mt, $yr);
}