tags:

views:

273

answers:

4

How can I find the standard site_perl (non-arch specific) location? Is it safe to just loop over @INC and find the path ending with "site_perl", or is there a standard way to do this?

The reason for trying to find this, is I have a very large project built up from hundreds of individual modules, all with their own Makefile.PL files (pretty much every .pm file has been built as its own CPAN style module). Along with this, each module may have artifacts (templates, .cgi's, etc), in various locations, all which need to be deployed to various locations, nothing is standard. This is the first step in trying to get this under control, basically having a single Makefile which can find and deploy everything, the next step will be getting it in sensible layout in version control.

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

+1  A: 

It is not safe to loop over @INC as it can be modified by code or the environment, and, therefore, may contain multiple directories that end in site_perl.

If you are trying to determine where a given module is installed use %INC.

Chas. Owens
Nope, I'm trying to find where to install a specific module. I have a high level of control over the installation targets, but cannot at this stage change @INC, nor due to the complexity can I use MakeMaker/etc.
Matthew Watson
perl -V | grep sitelib look for the -Dsitelib= value
Chas. Owens
@Chas. Owens: installsitelib, not sitelib
ysth
+6  A: 
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
Sinan Ünür
shorter way to do that: perl '-V:.*site.*'
ysth
@ysth Thanks for pointing that out. I had no idea you could use wildcards with -V.
Sinan Ünür
+2  A: 

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

jiggy
+4  A: 

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

But if you must, the directory is available (after loading Config) as $Config::Config{'installsitelib'}. Note that some platforms may configure perl such that this directory doesn't literally appear in @INC, instead having some other directory that's symlinked to the installsitelib directory.

ysth