Hello all,

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


In reply to Module not included but present in %INC! by truptivk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.