in reply to finding installed module directory

See perlvar - there's the special %INC hash, where modules loaded via do, require or use get recorded. The hash is keyed by module filename, the value is the path to it. The statement
warn "$_ => $INC{$_}\n" for sort keys %INC;
delivers the entire hash, sorted by keys, to STDERR.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: finding installed module directory
by jdtoronto (Prior) on Jul 07, 2006 at 18:20 UTC
    Funny, I have this in my 'debug' function:
    print "$_ => $INC{$_}\n" for sort keys %INC;
    which is a standard part of every job I do, that why I can be usre which modules, and from where they have been loaded. It also means that you can add directories to the search path, and you can see just what is happening, for example:
    #!/usr/bin/perl -w use strict; use FindBin; use lib "$FindBin::Bin/lib"; use InContact::Util; print "$_ => $INC{$_}\n" for sort keys %INC;
    In my actual debugging module I read a single HASH with the /lib pointed to, then one with it disabled, then I can 'substract' one fomr the otehr and find out what the dependencies for my own modules are.

    jdtoronto

      thanks,with:
      my $jroot=""; foreach my $a (keys %INC) {if ($INC{$a}=~/(.*)jinit.pm/){$jroot=$1}} die "I cannot find datadirectory\n" if ($jroot eq "");
      I got what I wanted.
      Still, I don't like to use the pattern "jinit.pm" (the module name itself) hardcoded inside, to find the current directory - but it's just a problem of elegance, nothing more...

      alessandro