Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Module not included but present in %INC!

by truptivk (Novice)
on Jan 06, 2012 at 16:49 UTC ( #946624=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Module not included but present in %INC!
in thread Module not included but present in %INC!

Thanks for your reply Corion
I reduced my pm file and wrote another .pl so as to reproduce the problem. Here they are: The test.pl file, which includes the .pm file:

#!/usr/bin/perl use strict; use warnings; use Dante::Correlation::CorrelationEngine; my $correlationEngine = Dante::Correlation::CorrelationEngine->new(1); $correlationEngine->testFunction(); exit;
The CorrelationEngine.pm file:
# # Dante::Correlation::CorrelationEngine.pm - Implements top-level co +rrelation logic. # ########## use strict; use warnings; use Date::Parse; # There are a bunch of other .pm includes here, but they are modules f +or the project, not any other perl module # There are other functions here, not listed, of course sub testFunction { 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"; } # Must return 1 for the class to be compilable. 1; # End of Dante::Correlation::CorrelationEngine.pm
Executing test.pl results in following error:
./test2.pl Undefined subroutine &Dante::Correlation::CorrelationEngine::str2time +called at Dante/Correlation/CorrelationEngine.pm line 664.

So if the culprit is CorrelationEngine.pm, how can I make sure it loads Date::Parse?
I'm at my wits end with this now; seems so simple, can't figure out why its not working.
Please help!
Trupti


Comment on Re^4: Module not included but present in %INC!
Select or Download Code
Re^5: Module not included but present in %INC!
by choroba (Abbot) on Jan 06, 2012 at 16:57 UTC
    Where is the package declaration?
Re^5: Module not included but present in %INC!
by Eliya (Vicar) on Jan 06, 2012 at 17:07 UTC

    You presumably have the package Dante::Correlation::CorrelationEngine declaration after the use Date::Parse statement — in which case the functions (like str2time) will be exported into main::, not Dante::Correlation::CorrelationEngine.

    When I put the package statement in the appropriate place, and add a constructor, the code works fine for me.

Re^5: Module not included but present in %INC!
by toolic (Chancellor) on Jan 06, 2012 at 17:41 UTC
    I modified test.pl and your .pm file. This works for me:
    $ find . . ./test.pl ./Dante ./Dante/Correlation ./Dante/Correlation/CorrelationEngine.pm $ $ $ cat Dante/Correlation/CorrelationEngine.pm # # Dante::Correlation::CorrelationEngine.pm - Implements top-level co +rrelation logic. # ########## package Dante::Correlation::CorrelationEngine; use strict; use warnings; use Date::Parse; # There are a bunch of other .pm includes here, but they are modules f +or the project, not any other perl module # There are other functions here, not listed, of course sub testFunction { 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"; } # Must return 1 for the class to be compilable. 1; # End of Dante::Correlation::CorrelationEngine.pm $ $ cat ./test.pl #!/usr/bin/env perl use warnings; use strict; use Dante::Correlation::CorrelationEngine; Dante::Correlation::CorrelationEngine::testFunction(); $ $ $ ./test.pl 1300430344 18010 1325791389 $
      Hello all!

      Yes indeed, the problem was where the package declaration went, and I'd put it after loading strict, warning, all other modules and of course, the Date::Parse module.
      I changed it and whew! Now it works :) Thank you everybody; I completely overlooked the package declaration line; oopsie!
      Thank you for your time and effort everybody, it is much appreciated :)

      Trupti

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946624]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (15)
As of 2014-07-10 10:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (205 votes), past polls