Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: How should I manage CPAN when using two versions of Perl in my computer?

by usemodperl (Beadle)
on Jun 30, 2018 at 17:50 UTC ( #1217659=note: print w/replies, xml ) Need Help??


in reply to Re^2: How should I manage CPAN when using two versions of Perl in my computer?
in thread How should I manage CPAN when using two versions of Perl in my computer?

use of perlbrew, requires to set an env-var and use #!/usr/bin/env perl as the shebang of all your perl scripts.

I love perlbrew but I love the shebang more. I could not look at env at the top of every perl script let alone type it. Shebang is holy and I found an easy way to preserve it to an acceptable degree and gained a very handy perlbrew switch. Like many others I have an untouched system perl and a main perlbrew with tons of cpan modules. My shebang preservation and toggle switch between system perl and perlbrew perl is achieved by making a symlink in the root directory called "user" that points to the main perlbrew path:

cd /
sudo ln -s /path/to/perl5/perlbrew/perls/perl-VERSION user

The main perlbrew path is found by typing "which perl" while brewing the main perlbrew perl and ignoring the /bin/perl part at the end. Now there are two shebangs with a single character switch that works everywhere:

#!/usr/bin/perl  # system perl
#!/user/bin/perl # perlbrew perl

On my system:

/usr/bin/perl -le 'print $^V'
v5.18.2

/user/bin/perl -le 'print $^V'
v5.26.2

This symlink has made me very happy! ☺

STOP REINVENTING WHEELS, START BUILDING SPACE ROCKETS!CPAN 🐪
  • Comment on Re^3: How should I manage CPAN when using two versions of Perl in my computer?

Replies are listed 'Best First'.
Re^4: How should I manage CPAN when using two versions of Perl in my computer?
by bliako (Monsignor) on Jul 01, 2018 at 09:59 UTC

    Thinking about it you can do this:

    % sudo ln -s /path/to/perl5/perlbrew/perls/perl-VERSION use$'\x010'r % echo /* /usr /usr

    It introduces a backspace in the filename of 'user' just after 'e'.

    but don't try it at home ... neither at work

      Getting rid of that symlink left as an exercise for the reader ...
        !
Re^4: How should I manage CPAN when using two versions of Perl in my computer?
by bliako (Monsignor) on Jul 01, 2018 at 09:35 UTC

    neat

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2022-12-06 20:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?