How to find the standard site_perl directory for Perl?

How can I find the default location of site_perl (non-arg)? Is it safe to simply iterate over @INC and find a path ending in "site_perl", or is there a standard way to do this?

Trying to find this, I have a very large project created from hundreds of separate modules, all with their own Makefile.PL files (almost every .pm file was created as its own CPAN style module). Along with this, each module can have artifacts (templates, .cgi, etc.). In different places, everything that needs to be deployed in different places, nothing is standard. This is the first step in trying to get it under control, basically having one Makefile that can find and deploy everything, the next step will get it in a reasonable layout in version control.

I spent time trying to do this with standard installation tools, but no luck.

+5
source share
4 answers
C:\Temp> perl -MConfig -e "print qq{$_ => $Config{$_}\n} for grep { /site/ } keys %Config"

  d_sitearch => define
  installsitearch => C:\opt\perl\site\lib
  installsitebin => C:\opt\perl\site\bin
  installsitehtml1dir =>
  installsitehtml3dir =>
  installsitelib => C:\opt\perl\site\lib
  installsiteman1dir =>
  installsiteman3dir =>
  installsitescript => C:\opt\perl\site\bin
  sitearch => C:\opt\perl\site\lib
  sitearchexp => C:\opt\perl\site\lib
  sitebin => C:\opt\perl\site\bin
  sitebinexp => C:\opt\perl\site\bin
  sitehtml1dir =>
  sitehtml1direxp =>
  sitehtml3dir =>
  sitehtml3direxp =>
  sitelib => C:\opt\perl\site\lib
  sitelib_stem =>
  sitelibexp => C:\opt\perl\site\lib
  siteman1dir =>
  siteman1direxp =>
  siteman3dir =>
  siteman3direxp =>
  siteprefix => C:\opt\perl\site
  siteprefixexp => C:\opt\perl\site
  sitescript =>
  sitescriptexp =>
  usesitecustomize => define

Or, as @ysth points out in the comments, you can use:

C:\Temp> perl -V:.*site.*

on windows and

 $ perl '-V:.*site.*'

in * nix shells.

+7
source

Is there a reason not to use one of the module installers ( ExtUtils :: MakeMaker , Module :: Build , Module :: Install )?

, ( Config) $Config::Config{'installsitelib'}. , perl , @INC, , installsitelib.

+5

Just run it perl -V. It will print by default @INC at the end.

+2
source

It is not safe to navigate through @INC, since it can be modified by code or the environment and therefore may contain several directories that end in site_perl.

If you are trying to determine where this module is installed, use %INC.

+1
source

All Articles