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

quick follow up question, one error message went away but didn't quite worked by adding the path to the files using use lib "path"... as follows

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

this is the error message, why is it asking me to pointing to a different directory I implicitly set?

Can't locate object method "class" via package "Da_corsa" (perhaps you + forgot to load "Da_corsa"?) at C:\Users\Lucca\Documents\NetBeansProj +ects\PERL scripts\perl\MioDreamcar.pl line 17.
use warnings; use Data::Dump qw(dump); use lib "C:/Users/Lucca/Documents/NetBeansProjects/perlpm"; #initial e +rror gone but other pop up. #use lib "C:/Users/Lucca/Documents/NetBeansProjects"; #tried to follow + example syntax for this method but didn't work #use perlpm::Da_corsa; #adding the file this way...why is this method +wrong.

created a different dir to do all my testing of future PM's...so the permission are set correctly

$ ls -lrt perlpm/ total 3 -rwxrwxrwx+ 1 Lucca Lucca 288 Nov 6 17:58 Scuderia.pm -rwxrwxrwx+ 1 Lucca Lucca 343 Nov 6 17:58 Dreamcar.pm -rwxrwxrwx+ 1 Lucca Lucca 569 Nov 6 17:58 Da_corsa.pm

Replies are listed 'Best First'.
Re^3: PM module question/improvements
by 1nickt (Canon) on Nov 07, 2015 at 03:16 UTC

    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.

      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

      you're right!

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