0

I have a script that must be run in Perl 5.10.1, although my university's linux cluster system uses the most recent version of Perl. I tried to install Perlbrew, but I don't think it worked.

I'm not sure how to specify the perl version in the shebang because of how I call/run this script. There is "cluster.pl", which is run by running "./command.txt".

Also, I don't think I can install Perlbrew because it's the university's linux system: After copy-pasting the installation commands, my terminal screen said the perlbrew patch was installed, but when I used "perlbrew install perl-5.10.1", it would say "command perlbrew not found" I don't know how to run the script

As of now, cluster.pl has this shebang:

#!/usr/bin/perl

One related question said to write this in the command line

/program/perl_v5.6.1/bin/perl scriptName.pl
#OP needed to use version 5.6.1, unlike me (I need 5.10.1)

However, I don't know whether "program" is OP's directory or a mandatory part of the path

Below is command.txt, which has the necessary input arguments:

#this is command.txt
./cluster.pl Datachr1 2 galGal5.Chroinfo.txt

Essentially, where would the suggested shebang go? Would I include "program" in my path too?

  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/194767/discussion-on-question-by-prinkessbambi-how-to-specify-which-version-of-perl-to). – Andy Jun 11 '19 at 13:49

1 Answers1

1

If you wrap your script in Perl's packaging framework, this is handled for you automatically. When it installs scripts, it changes the shebang line with the actual perl. You end up with something like this at the top of the file:

#!/usr/local/perls/perl-5.30.0/bin/perl
    eval 'exec /usr/local/perls/perl-5.30.0/bin/perl -S $0 ${1+"$@"}'
        if $running_under_some_shell;
#!/usr/local/bin/perl

You might try this with my app-rhich distribution. Download the tarball and run the Makefile.PL with the perl you want. Run make and it builds stuff into the blib staging directory. You should see the modified shebang there:

$ /Users/brian/bin/perls/perl5.30.0 MAkefile.PL
Checking if your kit is complete...
Looks good
WARNING: Older versions of ExtUtils::MakeMaker may errantly install README.pod as part of this distribution. It is recommended to avoid using this path in CPAN modules.
Generating a Unix-style Makefile
Writing Makefile for App::rhich
Writing MYMETA.yml and MYMETA.json

$ make build
make: *** No rule to make target `build'.  Stop.

$ make
cp lib/App/rhich.pm blib/lib/App/rhich.pm
cp script/rhich blib/script/rhich
"/usr/local/perls/perl-5.30.0/bin/perl" -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/rhich
Manifying 1 pod document
Manifying 1 pod document
brian@otter app-rhich  (master)[3125]

$ more blib/script/
#!/usr/local/perls/perl-5.30.0/bin/perl
package rhich;
use strict;
use warnings;

However, if your path to perl is a symlink to some other perl, this can get confused. I don't use perlbrew because I don't think it adds much other than saving you looking up a download URL. I install multiple perls (and How should I install more than one version of Perl?) and can use paths to them so I know which version using. There's a similar problem with env depending on how you set up your path. How you handle that is based on how you decide to manage things, but it's these sorts of questions that show that the tools of convenience aren't really that convenient.

brian d foy
  • 129,424
  • 31
  • 207
  • 592