truptivk has asked for the wisdom of the Perl Monks concerning the following question:
I'm facing a unique problem. Well, the background: I need to convert a date and time string (in format <yyyy-mm-dd hh:mm:ss>) into seconds since epoch, and perform some mathematical operation on it. After googling, I decided to use Date::Parse's str2time() function. I downloaded the module from CPAN and even wrote an extememely simple test program to test it. It is here:
#!/usr/bin/perl use strict; use warnings; use Date::Parse; print str2time("2011-03-18 02:39:04") . "\n"; print str2time("1970-01-01 00:00:10") . "\n"; print str2time("2012-01-05 14:23:09") . "\n"; exit;
Happy with it, I proceeded to use it in my actual code, which is a class file. In it, however, I get an error saying str2time() is not defined! Below is my class:
########## use strict; use warnings; use Date::Parse; <some more code here> $dashboardAlarmStartTime = $dashboardAlarm->startTime; print "dashboardAlarmStartTime: " . $dashboardAlarmStartTime . "\n"; $maxDashboardAlarmForGroupStartTime = $maxDashboardAlarmForGroup->star +tTime; print "maxDashboardAlarmForGroupStartTime: " . $maxDashboardAlarmForGr +oupStartTime . "\n"; my $timeDiff = str2time($dashboardAlarmStartTime) - str2time($maxDashb +oardAlarmForGroupStartTime); print "timeDiff: " . $timeDiff . "\n";
I get an error at the line my $timeDiff = str2time(). Where am I going wrong? I tried the following to verify that the module is indeed present:
perl -MDate::Parse -le 'print $INC{"Date/Parse.pm"}'
And the output was: /usr/lib/perl5/site_perl/5.8.8/Date/Parse.pm Please help me out here, I'd really appreciate it.
Thanks! Trupti
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Module not included but present in %INC!
by toolic (Bishop) on Jan 06, 2012 at 15:04 UTC | |
by Anonymous Monk on Jan 06, 2012 at 16:10 UTC | |
by Corion (Patriarch) on Jan 06, 2012 at 16:20 UTC | |
by truptivk (Novice) on Jan 06, 2012 at 16:49 UTC | |
by Eliya (Vicar) on Jan 06, 2012 at 17:07 UTC | |
by toolic (Bishop) on Jan 06, 2012 at 17:41 UTC | |
| |
by choroba (Cardinal) on Jan 06, 2012 at 16:57 UTC |