http://www.perlmonks.org?node_id=11118534


in reply to Best approach for temporarily swapping out a single perl module for a different version?

What I usually do in such a situation: I go to the ~/perl5 directory (created by local::lib), run
git init git add . git commit -m start
(if it's not already there, then I don't need to run anything).

Then I create a branch for experiments, e.g.

git checkout -b module-3.4
and actually upgrade the module.

Installing several different versions in different branches is possible, you can then use git to switch between them and compare the behaviour of your app or tests.

After the experiment is over, I either stay with the new version

git checkout master git merge module-3.4
or I return to master and delete the branch.

I described the process when I first used it in my blog.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
  • Comment on Re: Best approach for temporarily swapping out a single perl module for a different version?
  • Select or Download Code

Replies are listed 'Best First'.
Re^2: Best approach for temporarily swapping out a single perl module for a different version?
by nysus (Parson) on Jun 25, 2020 at 15:25 UTC

    Let me see if I got this straight because I'm not familiar with local::lib and I'm using perlbrew which created ~/perl5 for me.

    So basically you create a giant git repo for all the modules located in the root of ~/perl5? And then when you want to upgrade a single module, you create a new branch and modify that single module? Is that right?

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      Exactly. Adding a change can take a second or two, switching the branches is blazing fast.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        Very cool. One more question, though. I'm not very adept with git and trying to wrap my head around how I might incorporate your solution into my current setup.

        So I have a ~/git_repos directory for cloned modules from github where I keep perl modules that I contribute patches to. These repos track the upstream module and my own forked copy of the module. I also have a ~/perl/modules directory where I keep all my locally developed modules. These modules get installed to my local machine and they also get pushed out to cpan and github from this directory. This is where I modify my $PERL5LIB as appropriate to load the module from either ~/git_repos or ~/perl/modules.

        Do you have any suggestions for how I might be able manage these repos connected to github and still use your solution?

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks