Can't locate File/Glob.pm in @INC (@INC contains: D:/tools/lib .) at directory.pl line 2
Asked Answered
W

1

9

I get this error when running my perl code

Can't locate File/Glob.pm in @INC (@INC contains: D:/tools/lib .) at directory.pl line 2.

line 2: @files=<*>;

When i run the command, I get,

Y:\perl\perl>perldoc -l File::Glob

D:\tools\lib\perl\510\File\Glob.pm

So I think the File::Glob module is installed?

Winery answered 17/1, 2011 at 19:17 Comment(3)
It's installed, alright. Your @INC doesn't point to it, though.Wheatworm
Thanks, somehow I thought it would know how to search the subpath under D:/tools/libWinery
Why does perldoc find it if it's not in @INCPellagra
D
16

@INC should be set correctly upon installation of Perl. When it doesn't match your configuration, you seem to have messed up something.

However, if the current value of @INC doesn't fit your needs, you have various options:

  1. Add D:\tools\lib\perl\510\ to the environment variable PERL5LIB (or PERLLIB if this doesn't work)
  2. Specify @INC on startup: perl -I D:\tools\lib\perl\510\
  3. Instead of writing use libname, you can write use path/to/libname
  4. Using a BEGIN block before the use statements:

    BEGIN {
      push @INC,"D:\tools\lib\perl\510\";
    }
    

See also http://perldoc.perl.org/perlvar.html for a short introduction.

Denote answered 17/1, 2011 at 19:38 Comment(2)
resolved using the first suggestion; and thanks for providing so many alternative! "There's more than one way to do it"- I guess :)Winery
I guess, you should refrain from using slashes in Perl code under Windows, since these "\t", "\510" etc may be expanded to some weird characters. Using backslashes would be more appropriate, I guess.Unshakable

© 2022 - 2024 — McMap. All rights reserved.