Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Find perl module version from command-line

by Anonymous Monk
on Feb 21, 2012 at 13:26 UTC ( #955306=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Find perl module version from command-line
in thread Find perl module version from command-line

I know this is kind of an old thread, but I was wondering if anyone has any code that will recursively go through a directory structure and find ALL the PERL modules and then print out the version. My Red Hat Linux distro has /usr/local/lib/perl5 and then the sub-dirs 5.8.5 and site_perl. How would I sweep through these two sub-dirs, find all the .pm files, for example, and then have it give me the VERSION if a VERSION variable exist in the .pm file? The reason I ask is I have 4 machines which I must compare VERSIONs on. So if I can get the output into 4 individual files I can easily import the data into a spreadsheet and compare. I have a small bash script that seems to work, but I'm looking for an efficient PERL method. I am just learning PERL i.e. I'm a few pages into the 5th ED. of the O'Reilly book, so the coding required is still a bit over my head, yet I have this task to complete for the boss man. Any help you can offer would be greatly appreciated.


Comment on Re^4: Find perl module version from command-line
Re^5: Find perl module version from command-line
by geelsu (Initiate) on Feb 21, 2012 at 13:34 UTC

    Umm, I thought I was logged in when I posted ^4 of this thread. So ^4 and ^5 are from user geelsu. Also, this PERL install is on a private network with no access to the Internet so I can even get to CPAN for example.

Re^5: Find perl module version from command-line
by Corion (Pope) on Feb 21, 2012 at 13:34 UTC

    How about ack '^\s*\$VERSION'? See App::ack.

    Also, instead of using Excel, you might want to use sort and diff to find the differences between the machines.

      Thanks. I will try and see if I can get that. App::Ack is not in my current PERL install. All I have in App is something called Prove. We have this weird convoluted process to get files from the Internet to the private systems.

        App:Prove is part of the Test-Harness suite. Test::Harness itself has been bundled with Perl since Perl 5.0 (i.e. almost 20 years), but the App::Prove module is a later addition (since Perl 5.10.1).

      Or just
      grep 'VERSION' $(find . -name \*.pm -type f)
      which uses standard Unix tools.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-20 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (97 votes), past polls