chriso has asked for the wisdom of the Perl Monks concerning the following question:

When executing my script, I get the following error:
"Can't locate object method "new" via package "perl2UCS" (perhaps you forgot to load "perl2UCS"?) at sys:/perl/web/makequiz.cgi line 23."
Here is the code heading I'm using:
#!/usr/bin/perl use lib 'sys:\perl\lib'; use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use strict; use perl2UCS; use warnings; my ( @explain, @allanswers, @allquestions, $fullname, $anslength, @allselections, $file, $fname, $lname, $time, $reviewtime, $idinput, $id, $courselocation, $useripaddress, $questionno, @log, $clocktime, $log, $type, $value, @answers, $buttonname, %selections, @options, $nds ); # Create NWDir UCX object $nds = perl2UCS->new("UCX:NWDir"); # Set tree and context to login $nds->{"FullName"} = "nds:\\\\tree\\container"; $nds->login ("username", "password"); print header;
The perl module Perl2UCS is located in the sys:perl\lib directory. What am I missing? Thanks for any help you can provide.

Replies are listed 'Best First'.
Re: "Can't locate object method" error
by gellyfish (Monsignor) on Aug 16, 2005 at 12:10 UTC

    You appear to use both perl2UCS and Perl2UCS when talking about the module, you should bear in mind that whether or not your file system is case-sensitive, Perl is and you have to use the same case when referrring to the module as you have in the package declaration in the module itself.

    /J\

      Thanks. The perl module is with a capital P. I corrected my script and it works fine.

      Chris

Re: "Can't locate object method" error
by merlyn (Sage) on Aug 16, 2005 at 13:02 UTC
    my ( @explain, @allanswers, @allquestions, $fullname, $anslength, @allselections, $file, $fname, $lname, $time, $reviewtime, $idinput, $id, $courselocation, $useripaddress, $questionno, @log, $clocktime, $log, $type, $value, @answers, $buttonname, %selections, @options, $nds );
    I stopped reading here. This is almost always a warning that bad code follows. Saves me time that way.

    You might want to look at reducing the number of global variables in your program, and especially want to look into documenting your variables as you introduce them.

    -- Randal L. Schwartz, Perl hacker
    Be sure to read my standard disclaimer if this is a reply.

      I usually stop at
      use CGI;
      I find that this is often the introduction of a script that was thrown together in haste rather than well thought out and designed accordingly. :-)

      Ivan Heffner
      Sr. Software Engineer, DAS Lead
      WhitePages.com, Inc.
Re: "Can't locate object method" error
by anonymized user 468275 (Curate) on Aug 16, 2005 at 12:17 UTC
    Looking at some other examples, I note that they 'use Sockets;' before using perl2UCS when using method 'new'.

    Update: No, I think the simple uppercase first letter is more likely to fix it after all.

    One world, one people