My calendar script makes heavy use of Perl modules fetched from CPAN. But when I changed to a server running Perl 5.18, several modules did not install. Some of them do so because a deprecated syntax (Use of qw(...) as parentheses is deprecated) was finally removed in 5.18 and leads to a fatal error now. A relatively simple solution is to use perlbrew to build a local installation of an older Perl Version and than let the shebang line of your script point to it. The installation commands may vary in dependency of your operating system. The perlbrew page tells you more.
Since my server lacked the patch command I had to install it first:
$ sudo apt-get install patch
Then install perlbrew.
$ sudo cpan App::perlbrew $ perlbrew init
Append the displayed piece of code to .bash_profile or .profile and start a new shell. It is important to install the CPANminus module ahead of single Perl distributions in order to have it globally available.
$ perlbrew install-cpanm
Now you can install additional Perl distributions to your home directory and switch:
$ perlbrew install perl-5.10.1 $ perlbrew use perl-5.10.1
You can check the active Perl version with
$ perl -v This is perl, v5.10.1 (*) built for x86_64-linux (with 1 registered patch, see perl -V for more detail) Copyright 1987-2009, Larry Wall ...
Then install the modules you need with CPANminus into a version-specific directory:
$ cpanm Any::Module
At last find out where Perl is located …
$ which perl /home/username/perl5/perlbrew/perls/perl-5.10.1/bin/perl
… and finally point the shebang line of your script to it:
That’s all. The main drawback of this solution is that you cannot apply it to mod_perl since mod_perl employs an in-built Perl interpreter and therefore does not evaluate the shebang line. But of course it is much better to run your script with CGI than discarding it completely.
Leave a Reply