Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Module installed Path

by w-ber (Hermit)
on Mar 06, 2007 at 08:44 UTC ( #603364=note: print w/ replies, xml ) Need Help??


in reply to Module installed Path

I don't know if there's an official way, but here's what I could whip together:

sub find_installed_path { my $module_name = shift; # For Unix systems: $module_name =~ s!::!/!g; # For Windows: #$module_name =~ s!::!\\!g; $module_name .= '.pm'; foreach my $path (@INC) { next if (ref $path); return "$path/$module_name" if (-f "$path/$module_name"); } return ''; } print find_installed_path('File::Find');

YMMV, but works with Linux and Perl 5.8.8.

UPDATE: @INC may contain references (to subroutines, blessed objects, etc.), so added a check right at the beginning of the foreach loop.

--
print "Just Another Perl Adept\n";


Comment on Re: Module installed Path
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://603364]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-12-21 12:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (104 votes), past polls