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

Hi Monks, There is a case where there are say 30 + perl scripts all written by different people. Say one script , abc.pl begins with
!/tools/gnu/bin/perl-5.6.0-32bit -I./ use strict; use Data::Dumper; use File::Basename;
Many of the scripts could have different versions and different paths to packages. is there anyway that I could force them to this one version and point to the same directory path from the command line?

Replies are listed 'Best First'.
Re: Force Perl Version and path to packages
by thor (Priest) on Feb 25, 2005 at 20:39 UTC
    When you invoke a script, you can do it a couple of ways. One of them (the style that you're using) requires a shebang line and is invoked as such: "scriptname.pl". The other requires no shebang line (it actually ignores it if it's present): "perl scriptname.pl". In the latter way, you can be assured of running a consistent version of perl because you're specifying it at runtime. As for the -I flag that you're passing on the shebang line, for that particular script, it's probably unnecessary. '.' is usually in @INC. You can check by doing a "perl -V".

    thor

    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

      (it actually ignores it if it's present)

      Not entirely. Flags are still parsed from it. However, as you say, prepending a specific perl to the command line does have the effect of ensuring that the script is run under that particular perl.


      "In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68
        I'd like to say that I knew that, but I honestly didn't. I thought that perl treated that line as a comment. Perl wins again. :) Thanks for the education.

        thor

        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come