Home > Archive > PERL Beginners > October 2006 > an easy way to know if a module is installed or not
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
an easy way to know if a module is installed or not
|
|
| Zhihua Li 2006-10-04, 9:57 pm |
| hi netters,
I've a question about installed modules in perl. To get an idea as to
weather or not a specific module (say A.pm) is present in my perl I can
search if there's a A.pm in the directories specified by @INC. But isn't
there an easier way? Can I browse or even search through all the modules
already installed in perl directly instead of do the search?
Thank you very much!
| |
|
| zhihua li wrote:
> hi netters,
>
> I've a question about installed modules in perl. To get an idea as to
> weather or not a specific module (say A.pm) is present in my perl I
> can search if there's a A.pm in the directories specified by @INC. But
> isn't there an easier way? Can I browse or even search through all the
> modules already installed in perl directly instead of do the search?
>
> Thank you very much!
>
>
>
An easy way.
perldoc -m The::Module::You::Want;
or
perl -e "use The::Module::You::Want";
you 'll notice if the module is installed or not for the outcome result.
HTH,
Mug
| |
| Tom Phoenix 2006-10-05, 6:58 pm |
| On 10/4/06, zhihua li <lzhtom@hotmail.com> wrote:
> Can I browse or even search through all the modules
> already installed in perl directly instead of do the search?
You could use Inside:
http://search.cpan.org/~phoenix/Inside-1.01/
Hope this helps!
--Tom Phoenix
Stonehenge Perl Training
| |
| Greg Sabino Mullane 2006-10-05, 6:58 pm |
| On Thu, 2006-10-05 at 02:49 +0000, zhihua li wrote:
> I've a question about installed modules in perl. To get an idea as to
> weather or not a specific module (say A.pm) is present in my perl I can
If you are using bash, here's a handy alias I made you can put in your .bashrc file:
alias modver="perl -e\"eval qq{use \\\$ARGV[0];\\\\\\\$v=\\\\\\\$\\\${ARGV[
0]}::VERSION;};\
print\\\$@?qq{No module found\\n}:\\\$v?qq{Version \\\$v\\n}:qq{Found.\\n};\"\$1"
(it's two lines in case your mailer wraps: second line starts with "print")..
Usage examples:
$ modver DBD::Pg
Version 1.49
$ modver Acme::Dynamite
No module found
$ modver Data::Dumper
Version 2.121
--
Greg Sabino Mullane greg@endpoint.com greg@turnstep.com
End Point Corporation
PGP Key: 0x14964AC8 200610051111
http://biglumber.com/x/web? pk=2529...14964
AC8
| |
| Reginald Johnson 2006-10-05, 6:58 pm |
| To piggy back off of this question... Is there a way to just list out
the modules you have installed?
-----Original Message-----
From: Mug [mailto:perl@reborn.org]=20
Sent: Wednesday, October 04, 2006 11:24 PM
To: zhihua li
Cc: beginners@perl.org
Subject: Re: an easy way to know if a module is installed or not
zhihua li wrote:
> hi netters,
>
> I've a question about installed modules in perl. To get an idea as to
> weather or not a specific module (say A.pm) is present in my perl I
> can search if there's a A.pm in the directories specified by @INC. But
> isn't there an easier way? Can I browse or even search through all the
> modules already installed in perl directly instead of do the search?
>
> Thank you very much!
>
>
>
An easy way.
perldoc -m The::Module::You::Want;
or
perl -e "use The::Module::You::Want";
you 'll notice if the module is installed or not for the outcome result.
HTH,
Mug
--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
| |
| Chad Perrin 2006-10-05, 6:58 pm |
| On Thu, Oct 05, 2006 at 12:34:18PM -0400, Johnson, Reginald (GTI) wrote:
> To piggy back off of this question... Is there a way to just list out
> the modules you have installed?
This works for me:
#!/usr/bin/perl -l
use strict;
use warnings;
use File::Find 'find';
use File::Spec::Functions;
find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1
}, @INC;
(watch the line-wrap)
This recently came up in the PerlMonks chatterbox, too.
--
CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
"The ability to quote is a serviceable
substitute for wit." - W. Somerset Maugham
| |
| Paul Lalli 2006-10-05, 6:58 pm |
| Reginald Johnson wrote:
> To piggy back off of this question... Is there a way to just list out
> the modules you have installed?
perldoc ExtUtils::Installed
Paul Lalli
| |
| Mumia W. 2006-10-05, 6:58 pm |
| On 10/05/2006 11:34 AM, Johnson, Reginald (GTI) wrote:
> To piggy back off of this question... Is there a way to just list out
> the modules you have installed?
>
Make sure that perldoc is installed on your system and do this at a
command prompt:
perldoc -q installed
| |
| Reginald Johnson 2006-10-05, 6:58 pm |
| -----Original Message-----
From: Chad Perrin [mailto:perrin@apotheon.com]=20
Sent: Thursday, October 05, 2006 1:11 PM
To: beginners@perl.org
Subject: Re: an easy way to know if a module is installed or not
On Thu, Oct 05, 2006 at 12:34:18PM -0400, Johnson, Reginald (GTI) wrote:
> To piggy back off of this question... Is there a way to just list out
> the modules you have installed?
This works for me:
#!/usr/bin/perl -l
use strict;
use warnings;
use File::Find 'find';
use File::Spec::Functions;
find { wanted =3D> sub { print canonpath $_ if /\.pm\z/ }, no_chdir =
=3D> 1
}, @INC;
(watch the line-wrap)
--=20
Thanks, that's just what I was looking for.
--------------------------------------------------------
If you are not an intended recipient of this e-mail, please notify the =
sender, delete it and do not read, act upon, print, disclose, copy, =
retain or redistribute it. Click here for important additional terms =
relating to this e-mail. http://www.ml.com/email_terms/
--------------------------------------------------------
|
|
|
|
|