in reply to Re^2: PM module question/improvements
in thread PM module question/improvements

at C:\Users\Lucca\Documents\NetBeansProjects\PERL scripts\perl\MioDreamcar.pl line 17. is telling you the line and file where the error occured; in this case the error occurred when you tried to LOAD Da_corsa.

The error message Can't locate object method "class" via package "Da_corsa" (perhaps you forgot to load "Da_corsa"?) is telling you that Perl still can't find a valid package of that name. The reason is probably that you are forgetting to return a true value at the end of your package, i.e. your module Da_corsa.pm should be like:

package Da_corsa; use strict; use warnings; sub foo { return 'bar'; } 1; # return true
In your original post the other two packages return true but Da_corsa doesn't.

Given the various comments and such in your latest example, once your module returns true, you might have success with:

use lib "C:/Users/Lucca/Documents/NetBeansProjects/perlpm"; use Da_corsa;

Hope this helps!

The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^4: PM module question/improvements
by Anonymous Monk on Nov 07, 2015 at 03:26 UTC

    Another reason for this error, if your paths and @INC are right, could be that you are forgetting to return a true value at the end of your package, i.e. your module Da_corsa.pm should be like:

    Nope, perl catches that

    $ echo package Shoo; sub foo { warn rand }; > Shoo.pm $ perl -I. -MShoo -e Shoo::foo Shoo.pm did not return a true value. BEGIN failed--compilation aborted.

    With the code he posted this new error isn't possible ... so he must not be running the code he posted

Re^4: PM module question/improvements
by perlynewby (Scribe) on Nov 07, 2015 at 04:05 UTC

    you're right!

    thanks for seeing this as my eyes were not catching this and never seen error message and resolve it