CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
how to check which perl stuff (modules) is running on my opensuse 12.3

 



dilbert
User

Jun 21, 2013, 10:34 AM

Post #1 of 17 (939 views)
how to check which perl stuff (modules) is running on my opensuse 12.3 Can't Post

 
good day dear perl-experts


how to check which perl stuff (modules) is running on my opensuse 12.3
note - i sometimes was being forced to install via repo

the method to instal via cpan was being looked very very "harmful".


at the console
perl -MCPAN -e shell
on first run you'll need to configure it, just follow defaults, get local repositories

so if we want to install - for example this one we go like this


cpan> install HTML::TreeBuilder::LibXML
and we should be good, or the package manager may allow you to install Perl modules as well


Again the questions: how to check which Perl-Module are installed!?


FishMonger
Veteran / Moderator

Jun 21, 2013, 11:15 AM

Post #2 of 17 (935 views)
Re: [dilbert] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

Do you need/want to check for specific module(s), or do you want to list all of the installed modules.

For a single module, you just need to test if it loads.
perl -MHTML::TreeBuilder::LibXML -e 1

If you receive an error, then it isn't installed. If you don't get any output, then it's installed.

If you need to find all modules, you'll need to search for .pm files under the @INC dirs.


(This post was edited by FishMonger on Jun 21, 2013, 11:15 AM)


dilbert
User

Jun 21, 2013, 11:40 AM

Post #3 of 17 (931 views)
Re: [FishMonger] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

hi there good evening dear fishmonger

i want to list all the modules i have installed on the linux.

well i guess that i can use commandline here.


Laurent_R
Veteran / Moderator

Jun 21, 2013, 11:58 AM

Post #4 of 17 (928 views)
Re: [dilbert] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

To start with, you can do something like this:


Code
$ perl -e 'print "$_ \n" foreach @INC'


which will display the list of directories where to look.

If under Windows, try to change it to this:


Code
perl -e "print qq($_ \n) foreach @INC"


(But I haven't tried it, not having a Perl install under Windows.)


FishMonger
Veteran / Moderator

Jun 21, 2013, 12:57 PM

Post #5 of 17 (927 views)
Re: [Laurent_R] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

From the File::Find::Rule synopsis

Code
  # find all the .pm files in @INC 
my @files = File::Find::Rule->file()
->name( '*.pm' )
->in( @INC );



FishMonger
Veteran / Moderator

Jun 21, 2013, 1:07 PM

Post #6 of 17 (924 views)
Re: [Laurent_R] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

FYI, the File::Find::Rule approach does work on Windows

c:\test>perl -M5.10.1 -MFile::Find::Rule -e "say $_ for File::Find::Rule->file()->name( '*.pm' )->in( @INC )"


Laurent_R
Veteran / Moderator

Jun 21, 2013, 2:48 PM

Post #7 of 17 (920 views)
Re: [FishMonger] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

Yes, right, this is probably better to get immediately the list of modules, but you might have to install File::Find::Rule beforehand, since this is apparently not a standard module.

A simple alternative without having to install any new module:


Code
$ perl -M5.10.1 -e 'for $dir (@INC) {say for glob "$dir/*.pm";}'


Under Windows, this would have to be changed to something like this (again untested under Windows):


Code
perl -M5.10.1 -e "for $dir (@INC) {say for glob qq($dir/*.pm);}'



(This post was edited by Laurent_R on Jun 21, 2013, 2:50 PM)


FishMonger
Veteran / Moderator

Jun 21, 2013, 3:06 PM

Post #8 of 17 (915 views)
Re: [Laurent_R] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

But that only gives you the modules at the top level. It does not recurse, which is needed to get all of the modules. In my case that's a difference of 3100 modules that your glob approach missed.


Laurent_R
Veteran / Moderator

Jun 21, 2013, 4:11 PM

Post #9 of 17 (913 views)
Re: [FishMonger] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

Yes, you're right, I did not think about recursing into directories.

I am amazed at this difference of 3100 modules. How many modules do you have installed in total? I personally have less than a thousand in total. And I don't really want more, I am working on several dozens environments, many of which it is difficult or impossible to obtain module installation, so I am using non standard modules only on environments where I can control what is going on.

Just one question that I am really interested in knowing, do you get the module count right (or much closer) with the following syntax trying to use recursive traversing of dirs:


Code
$ perl -M5.10.1 -e 'sub search {for $d (glob "$_[0]/*.p*") { if (-d $d) {search $d} else {say $d };}} search $_ for (@INC)'


I must say that this is probably the first time that I am using recursion in a Perl one-liner, but why not after all, even if I must confess this is getting a bit hairy for a one-liner. Well, this is a quick 10-min try, it seems to work, but there maybe some mistakes.

Please let me know if any.


FishMonger
Veteran / Moderator

Jun 21, 2013, 4:48 PM

Post #10 of 17 (911 views)
Re: [Laurent_R] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

I was on my work system when I ran the test and I'm home now, but from what I remember, the total was 3203.

Here are the numbers from my home system.

File::Find::Rule returns 3193 modules.

Your latest glob version returns 156 modules.

Results are attached.
Attachments: file-find.txt (176 KB)
  glob.txt (5.88 KB)


dilbert
User

Jun 22, 2013, 2:58 AM

Post #11 of 17 (902 views)
Re: [FishMonger] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

hello fishmonger hello Laurent

many many thanks


Code
martin@linux-70ce:~>  perl -e 'print "$_ \n" foreach @INC' 
/usr/lib/perl5/site_perl/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2
/usr/lib/perl5/vendor_perl/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.16.2
/usr/lib/perl5/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/5.16.2
/usr/lib/perl5/site_perl/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2
/usr/lib/perl5/site_perl
.
martin@linux-70ce:~>


a bit funny isnt it ?


Laurent_R
Veteran / Moderator

Jun 22, 2013, 3:12 AM

Post #12 of 17 (902 views)
Re: [FishMonger] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

Alright, my search function was not really recursing because I forgot to put parens around the arguments passed to it. Also, looking for the "*.p*" pattern eliminated the subdirectories from the search.

This version does seem to recurse properly and finds 5,431 matches:


Code
$ perl -M5.10.1 -e 'sub search {for $d (glob "$_[0]/*") { -d $d ? search ($d) : say $d;}} search ($_) for (@INC)' | wc 
5431 5431 341742



dilbert
User

Jun 22, 2013, 9:00 AM

Post #13 of 17 (888 views)
Re: [Laurent_R] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

 

i tried the follwing



Code
perl -e 'print "rpm -qf  $_\n" foreach @INC'|/bin/sh|sort -u







Code
o conf commit 
martin@linux-wyee:~/php> firefox -repl
martin@linux-wyee:~/php> perl -e 'print "rpm -qf $_\n" foreach @INC'|/bin/sh|sort -u
file /home/martin/php is not owned by any package
perl-5.16.0-3.5.1.i586
perl-base-5.16.0-3.5.1.i586
perl-B-Utils-0.21-2.1.2.i586
perl-Class-C3-XS-0.13-12.1.2.i586
perl-Class-Load-XS-0.04-4.1.2.i586
perl-Data-Dump-Streamer-2.33-2.1.2.i586
perl-Devel-GlobalDestruction-0.04-3.1.1.i586
perl-Digest-MD4-1.5-154.1.2.i586
perl-Digest-SHA1-2.13-11.1.2.i586
perl-gettext-1.05-157.1.2.i586
perl-HTML-Parser-3.69-12.1.2.i586
perl-HTTP-Server-Simple-0.44-2.1.1.i586
perl-List-MoreUtils-0.33-2.1.2.i586
perl-Moose-2.0602-2.1.2.i586
perl-Net-DBus-1.0.0-3.1.2.i586
perl-Net-LibIDN-0.12-9.1.2.i586
perl-Net-SSLeay-1.42-3.1.2.i586
perl-Package-Stash-XS-0.25-4.1.2.i586
perl-PadWalker-1.92-12.1.2.i586
perl-Params-Util-1.07-2.1.2.i586
perl-Sub-Name-0.05-21.1.2.i586
perl-Task-Weaken-1.04-14.1.1.i586
perl-Test-Exception-0.31-13.1.1.i586
perl-Text-CSV_XS-0.87-2.1.2.i586
perl-Unicode-Map-0.112-6.1.2.i586
perl-Variable-Magic-0.48-2.1.2.i586
perl-X11-Protocol-0.56-7.1.1.i586
perl-XML-LibXML-1.95-4.1.2.i586
perl-XML-NamespaceSupport-1.11-15.1.1.i586
perl-XML-Parser-2.41-15.1.2.i586
martin@linux-wyee:~/php>


greetings


dilbert
User

Jun 22, 2013, 9:16 AM

Post #14 of 17 (887 views)
Re: [dilbert] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

 

question - does this list "ALL" (!!) packages and modules on the whole machine!?
that is the question of the day....

look forward to hear from you

greets dilbet


FishMonger
Veteran / Moderator

Jun 22, 2013, 9:47 AM

Post #15 of 17 (884 views)
Re: [dilbert] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

No it doesn't; not even close.


Laurent_R
Veteran / Moderator

Jun 22, 2013, 10:36 AM

Post #16 of 17 (880 views)
Re: [dilbert] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post


In Reply To

Code
martin@linux-70ce:~>  perl -e 'print "$_ \n" foreach @INC' 
/usr/lib/perl5/site_perl/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2
/usr/lib/perl5/vendor_perl/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.16.2
/usr/lib/perl5/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/5.16.2
/usr/lib/perl5/site_perl/5.16.2/i586-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2
/usr/lib/perl5/site_perl
.
martin@linux-70ce:~>


a bit funny isnt it ?


Why should it be funny? It looks like a typical @INC content under Linux (remember @INC contains a list of directories where Perl looks for loading a module).


dilbert
User

Jun 22, 2013, 12:35 PM

Post #17 of 17 (876 views)
Re: [FishMonger] how to check which perl stuff (modules) is running on my opensuse 12.3 [In reply to] Can't Post

hello dear Laurent


thx for this answer.


In Reply To
No it doesn't; not even close.


i was thinkin that this is true - that this is the case!


well the problem is: i guess that i messed up my one - not both - lappy

i have done something wrong with the perl-installation - so i am not able to install

mozrepl with
Mechanize FireFox

if you have a closer look at the other threads - then you see what i mean.

note: i confess that many many ppl say that the installation of mozrepl with
Mechanize FireFox is not easy


but - i want to get to know why it fails... so i thougth i have to make a plan of all modules ans perl installations that run on the machine...

BY the way: i s it possible to create a DVD with Puppy - that runs


mozrepl with
Mechanize FireFox


look fowarrd to hear from you

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives