in reply to Module Self-Location

Embrace the %INC hash. $INC{"MyModule.pm"}

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Module Self-Location
by impossiblerobot (Deacon) on Feb 08, 2002 at 16:54 UTC
    Thanks, japhy! I spent a lot of time searching all over the place because I thought I had seen an easy way to do this. But I had forgotten that %INC was setting there holding just exactly the information I was looking for. :-)

    Update: Here's my updated self-locating module:
    package MyModule; use strict; my $inc_dir = $INC{'MyModule.pm'}; $inc_dir =~ s!/MyModule.pm$!!; print "MyModule found at: $inc_dir\n"; 1;
    Update 2: After a little more searching, I finally found the original node I was looking for: Read a static file from module directory.

    Impossible Robot