Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Get List of installed CPAN modules with timestamp for CPAN modules dependency resolution

by programmingzeal (Acolyte)
on Jul 05, 2021 at 07:21 UTC ( #11134656=perlquestion: print w/replies, xml ) Need Help??

programmingzeal has asked for the wisdom of the Perl Monks concerning the following question:

I am frequently confronted with re-installation of Strawberry Perl modules on Windows as ActiveState Perl is not available easily for installation, they have changed its installer download method. Every time I do fresh installation of strawberry Perl I have to install CPAN modules which often require dependency resolution which pose problem when certain dependency is not resolved particularly on windows. Also, simple copy paste of installed modules (.pm and .pl files/directories) from Strawberry Perl source directory to destination does not work and problems arise later on. I hit upon an idea. We know that in Strawberry distribution, the installation path of CPAN modules is 'C:\Strawberry\perl\site\lib' We can traverse a list of files (.pm and .pl) in above directory recursively along with file timestamp data (file creation date) and keep the list of installed .pm files chronologically saved. This way, whenever I have to do fresh Perl installation of CPAN modules I have the information that which module is required to be installed before other dependent module. The basic module installed on top of the list will be with no dependency and all such modules comes early in the list. All the modules with no dependency will come early in the list. Will my approach work or are there any workarounds of solving this issue of dependent modules installation. For getting list of installed CPAN modules along with .pm/.pl creation date time, I have developed the following code which is working:
use strict; use warnings; use Data::Dumper; use File::Find; my @file_list; my $directory = 'C:\Strawberry\perl\site\lib'; my ($file, $time, $ctime); find ( \&wanted, $directory ); sub wanted { return unless -f; return unless /\.(pl|pm)$/; $file = $File::Find::name; $ctime = (stat $File::Find::name)[10]; $time = scalar localtime($ctime); push (@file_list, [$file, $time]); } print Dumper @file_list;
I have about 3000 .pm and .pl files in my current Strawberry Perl Distribution which I am going to wipe-out.
  • Comment on Get List of installed CPAN modules with timestamp for CPAN modules dependency resolution
  • Select or Download Code

Replies are listed 'Best First'.
Re: Get List of installed CPAN modules with timestamp for CPAN modules dependency resolution
by Corion (Pope) on Jul 05, 2021 at 07:30 UTC

    You can also create a "Bundle" file using the autobundle command of the cpan client to list all modules for later reinstallation:

    cpan -a ... Package namespace installed latest in CPAN file + Algorithm::C3 0.10 0.11 HAARG/Algorithm-C3-0.11 +.tar.gz Algorithm::Diff 1.1903 1.201 RJBS/Algorithm-Diff-1.2 +01.tar.gz ... Wrote bundle file /home/corion/.local/share/.cpan/Bundle/Snapshot_2021_07_05_00.pm

    The list of modules listed in this bundle can then be installed in another environment using:

    perl -MCPAN -e 'install Bundle::Snapshot_2021_07_05_00'

    (as the module itself says)

Re: Get List of installed CPAN modules with timestamp for CPAN modules dependency resolution
by Anonymous Monk on Jul 05, 2021 at 07:48 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11134656]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2021-09-25 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?