Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Do you know where your variables are?

Module not included but present in %INC!

by truptivk (Novice)
on Jan 06, 2012 at 14:42 UTC ( #946605=perlquestion: print w/ replies, xml ) Need Help??
truptivk has asked for the wisdom of the Perl Monks concerning the following question:

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/"}'

And the output was: /usr/lib/perl5/site_perl/5.8.8/Date/ Please help me out here, I'd really appreciate it.

Thanks! Trupti

Comment on Module not included but present in %INC!
Select or Download Code
Re: Module not included but present in %INC!
by toolic (Chancellor) on Jan 06, 2012 at 15:04 UTC
    Add this to your "class file" (whatever that means):
    print $INC{"Date/"}; use Data::Dumper; print Dumper(\@INC);
    Also, copy-and-past the exact error message you are getting in your OP.

    Can you reduce your class file to the minimum number of lines which still reproduce your problem?

    Update: another possibility... does your class file have a different shebang line from your script (#!/usr/bin/perl)?

      Hello toolic,

      Thank you for your reply. My bad, I meant perl module when I said class file. Sorry about that.

      This is the output after I added your lines to the file:
      /usr/lib/perl5/site_perl/5.8.8/Date/$VAR1 = [ '/usr/local/nagios/libexec', '/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi' +, '/usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi' +, '/usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi' +, '/usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi' +, '/usr/lib/perl5/site_perl/5.8.8', '/usr/lib/perl5/site_perl/5.8.7', '/usr/lib/perl5/site_perl/5.8.6', '/usr/lib/perl5/site_perl/5.8.5', '/usr/lib/perl5/site_perl', '/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-mult +i', '/usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-mult +i', '/usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-mult +i', '/usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-mult +i', '/usr/lib/perl5/vendor_perl/5.8.8', '/usr/lib/perl5/vendor_perl/5.8.7', '/usr/lib/perl5/vendor_perl/5.8.6', '/usr/lib/perl5/vendor_perl/5.8.5', '/usr/lib/perl5/vendor_perl', '/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi', '/usr/lib/perl5/5.8.8', '.' ];

      The error message I get is:
      Undefined subroutine &Dante::Correlation::CorrelationEngine::str2time +called at /usr/local/nagios/libexec/Dante/Correlation/CorrelationEngi line 644.

      The only way to reduce the pm into minimum number of lines would be which I had written. Only difference is that I have another .pl script which includes
      Thanks for your help.
        Undefined subroutine &Dante::Correlation::CorrelationEngine::str2time +called at /usr/local/nagios/libexec/Dante/Correlation/CorrelationEngi line 644

        This means that the offending code lives in /usr/local/nagios/libexec/Dante/Correlation/, and my guess is that the file in question does not load Date::Parse.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://946605]
Approved by marto
Front-paged by toolic
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-04-17 22:34 GMT
Find Nodes?
    Voting Booth?

    April first is:

    Results (458 votes), past polls