in reply to Re: Can't locate object method "new" via package ... perhaps you forgot to load...Oh yes I did!
in thread Can't locate object method "new" via package ... perhaps you forgot to load...Oh yes I did!

Your file Syringe.pm still contains errors that strict.pm cannot let pass. So you are still loading the wrong Syringe.pm file (or loading the right one but modifying/posting the wrong one).

First test that Syringe.pm compiles well:

perl -Ilib -MSyringe -e1

If this command raises any errors, then they are in Syringe.pm.

Then, go on to put this into a (very small) Perl script:

#!perl -w use strict; use Syringe; print "OK\n";

Get this script to run.

After that, continue to add stuff until it breaks again (but by then, it shouldn't).

When debugging some "magic module loader" stuff (which I've since come to abhor, for the ugly things hidden by magic module loading), I've often resorted to putting BEGIN blocks into the modules that output "I am here" messages:

package My::Module; BEGIN { print "Loading " . __PACKAGE__ . " from " . __FILE__ . "\n"}; ... the methods in My::Module ... print "Loaded " . __PACKAGE__ . " from " . __FILE__ . "\n"; 1; __END__

This spews a lot of messages, but on the upside, you get a trace of what module gets loaded from where (and when). If there is a "Loading..." message, but no corresponding "Loaded..." message, then you know that there was an error and something along the way gobbled up and hid that error instead of stopping execution.

  • Comment on Re^2: Can't locate object method "new" via package ... perhaps you forgot to load...Oh yes I did!
  • Select or Download Code