> 
> Hi all,
>  
> i am new to using perl...
>  
> i want to use perl modules in my code.
>  
> can any one tell me how to load a perl module so that it can be used!!!
>  
> I am trying to use a module named Nary.pm in my code... tree.pl
> first line of my code says....
>  
> use Nary;   # Module in the same dir as the script
>  
>  
> Can't locate object method "new" via package "Nary" (perhaps you
forgot to load "Nary"?) at tree-trial.pl line 3.
>  
> can anyone tell me where i am going wrong!!!
>  
>

Now that I have thought about this I have a feeling the problem isn't
the location of the library, as the other posters suggested. Otherwise
you would be getting a "Can't locate module Nary.pm in @INC..." error. 
Which means I suspect you are running your script from the same
directory that it lives in, with a ./tree-trial.pl, etc.

So I suspect your first problem will be that you don't have a 'package
Nary' in the top of the module source, which is why you are getting the
Can't locate 'new' method *and* getting the 'perhaps you forgot to load
Nary' suggestion.  If the method was missing but the package was there
you would get only the first half.

So you likely need to back up a couple of steps, think about what you
are doing, and then do some reading:

perldoc -f package
perldoc -f use
perldoc perlmod
perldoc perlmodlib
perldoc perlmodstyle

To make your modules more generic you should listen to the advice of the
other posters though, as it will allow your scripts to be decoupled from
the module installation location.

If you aren't using 'strict' and 'warnings' right now you should be....

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to