Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Can't find module error

by kirk123 (Beadle)
on Apr 15, 2003 at 18:39 UTC ( #250639=perlquestion: print w/replies, xml ) Need Help??
kirk123 has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am getting a "Can't locate in @INC (@INC contains: c:\h\coe\comp\perl\lib c:\perl\lib c:\perl\lib\site c:\perl 3. BEGIN failed--compilation aborted at line 3." error. The is actually located in another directory(c:\h\COTS\Perl\lib\File). How can I update @INC to look there or is there a way I can specify the "use function" to look in another directory for --thanks

Replies are listed 'Best First'.
Re: Can't find module error
by arturo (Vicar) on Apr 15, 2003 at 18:51 UTC

    The problem is that the name of the module is File::Find, not just Find

    Since it is part of the standard Perl distribution, it will Just Work if you replace

    use Find;
    in your script with
    use File::Find;

    The reason is that Perl modules have name spaces, and the structure of these name spaces are reflected in directory structures; the "File" namespace is for modules deal with files and filesystems, and "Find" is one of the modules in that namespace. Thus, when you say use File::Find, perl searches for File/ in the directories in the @INC array. If you look in the directory where resides, you'll see that there are all sorts of other files with names like, and at the top of every one of them will be a line that says package File::[filename];, where "filename" is the name of the file you're looking at minus its ".pm" extension.


    If not P, what? Q maybe?
    "Sidney Morgenbesser"

Re: Can't find module error
by cbro (Pilgrim) on Apr 15, 2003 at 18:47 UTC
    use lib 'c:\h\COTS\Perl\lib';
    To the top of your script to search for the module in a non standard directory(e.g. Those not specified in @INC).
      Chris, It did not work. I am getting the following error"
      Can't locate in @INC
      (@INC contains: c:\h\coe\comp\perl\lib\site c:\h\coe \comp\perl\lib c:\perl\lib c:\perl\lib\site c:\perl\lib\site .)
      at line 3.
      BEGIN failed--compilation aborted at line 3.
      my scripts as follow:
      #!/h/COE/Comp/Perl/bin/perl use lib `c:/h\COTS\Perl\lib`; use File::Find; find(\&wanted,'/h', '/h/COE' ); sub wanted{ #-d $_ && print "$File::Find::name\n"; }

      2003-04-16 edit by ybiC: <tt> for error message, <code> for script

        Sorry to respond so late, but I was already gone by the time you responded. I doubt you'll still see this, but I'll check for updates regardless.

        Did arturo's response point you in the right direction? If not, do you have an update or still need help? Let us know if you're still stuck.

Re: Can't find module error
by LAI (Hermit) on Apr 15, 2003 at 18:49 UTC

    The following:

    use lib 'c:\h\COTS\Perl\lib\';

    Should do what you want. This is the preferred interface to @INC, rather than modifying it directly.

    Update: It occurred to me that your entire perl distribution might be in C:\h\COTS. If so, you likely want to modify your installation of perl to reflect that. I'm not clear on where stuff is in Windows, but you likely have a Perl.ini or something like that, where the default @INC is defined. Append to (or replace) the directories in the .ini with your path, and it should be good.

    That is, assuming the machine is your own and doing the above wouldn't break anyone else's perl :)

    Update: Silly double-quotes. They're single now. Thanks, chromatic!



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://250639]
Approved by sschneid
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2017-10-20 01:55 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (258 votes). Check out past polls.