in reply to Add current working directory to @INC?

"." is not in the module search path for my computer, I am using WindowXP and Activeperl. So how to make "." as one of my @INC?. TQ
  • Comment on Re: Add current working directory to @INC?

Replies are listed 'Best First'.
Re^2: Add current working directory to @INC?
by bart (Canon) on Jul 18, 2004 at 10:13 UTC
    Are you "deaf" or something?
    use lib '.';

    To be on the safe side, and if you plan on chdirring in your script, it's safer to do

    use Cwd; use lib cwd;
    cwd(), short for the "current working directory", is a function in Cwd that returns the absolute path for the current directory, thus ".".

    More flexible still is something like

    use File::Spec::Functions 'rel2abs'; use lib rel2abs('.');
    because this way it's easy to add an absolute path out of a specified relative path, say a subdirectory of the current directory:
    use File::Spec::Functions 'rel2abs'; use lib rel2abs('lib');

    In general, I prefer to use the functions from File::Spec::Functions, but if you don't use it for anything else, I'd avoid the namespace pollution from importing the sub name, and use the more convoluted syntax using the methods:

    use File::Spec; use lib File::Spec->rel2abs('lib');
Re^2: Add current working directory to @INC?
by wfsp (Abbot) on Jul 18, 2004 at 11:01 UTC
    I have winXP, ActiveState and a dot.
    for (@INC){ print "$_\n" }
    outputs:
    C:/Perl/lib C:/Perl/site/lib .
    In a cgi script with taint on the dot gets stripped. Is that what you are doing?
      same setup here, and it looks in the script dir just fine.