Wrapper on magic line?

Discussion in 'Perl' started by Nilsson Mats, Dec 9, 2003.

  1. Nilsson Mats

    Nilsson Mats Guest

    Hi!

    I have an intresting problem for our programming community on Solaris.

    I want to develop an environment where:
    1) The developers shouldn't need to bother about which Perl version to use.
    2) When the Perl version is changed in a controlled manner, the change should be instant.
    3) For developers whose scripts fails after a Perl version change, there should be a roll-back possibility.

    The infra structure in our department provides a cornucopia of Perl versions.
    These are installed under eg. /app/perl/5.8.1/bin/perl
    Furthermore, to support a specific version of Perl you have to run a script that modifies
    your $PATH so that that specific Perl is found first in the PATH.


    Some solutions that I have tried:


    Solution 1:
    Put the explicit path to your Perl interpretator as the magic line, eg:
    Of course, you have to run the script that modifies your PATH prior to the script execution.

    A script example:
    #!/app/perl/5.8.1/bin/perl
    printf "Hello, World!\n";

    The drawback is that you have to update gazillions of magic lines when wechange to a new Perl version.


    Solution 2:
    Use a symbolic link to point to your current Perl version.
    Still you have to run the script that modifies your PATH prior to the script execution.

    A link example:
    ln -s /app/perl/5.8.1/bin/perl /home/foobar/current_perl

    A script example:
    #!/home/foobar/current_perl
    printf "Hello, World!\n";

    The (smaller) drawback is that you have to edit the magic line if you deliberately want to override the Perl version.


    Solution 3:
    Use a wrapper that selects a Perl from the path.
    Still you have to run the script that modifies your PATH prior to the script execution.

    A script example:
    #!/usr/bin/env perl
    printf "Hello, World!\n";

    If you don't like the selected Perl you can re-modify your PATH an continue.


    Additions requirements:
    When investigating this I found that you sometimes want to save your scripts in a CM-system,
    eg. ClearCase. Furthermore you want to execute old verions of a script with that old Perl version that
    exixtsed when it was developed.

    Solution 4: (A combination of 2 and 3)
    First you have a symbolic link in your CM-system that points to your selected Perl version.
    This link is baselines along with the script source.

    A link example:
    ln -s /app/perl/5.8.1/bin/perl /vobs/foobar/current_perl

    Secondly, you have a better wrapper that you put in the magic line:

    A script example:
    #!/vobs/foobar/perlwrapper
    printf "Hello, World!\n";

    The wrapper does ths following:
    1) Checks if the environment (PATH etc.) is compatible with the Perl thatis pointed to by the
    symbolic link.
    2) If not, the environment is adjusted, using the script mentioned above.
    3) Starts Perl.

    Now my problem:
    Where to find info of how to write such a wrapper.

    --
    Hälsningar/Regards,
    -----------------------------------------------------------------
    Mats Nilsson
    ENEA Embedded Technology AB,Box232,Nytorpsv. 5,183 23 TÄBY SWEDEN
    http://www.enea.se +46850714626 +46709714626
    http://www.algonet.se/~gafvelin +4687201233
    PGP 0x9EC47877 40D5AB62551ED1A0DEDE1FFBCF0F5B2D9EC47877
    PGP 0x91BAB71D DEF5B01307C484C31CEE15DEE345166891BAB71D
    PGP 0x5DA31679 18449D0BE17C96C9D440CA96CF8BC0E0
    -----------------------------------------------------------------
    Nilsson Mats, Dec 9, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugo
    Replies:
    10
    Views:
    1,299
    Matt Humphrey
    Oct 18, 2004
  2. Edvard Majakari
    Replies:
    4
    Views:
    540
    Edvard Majakari
    May 27, 2004
  3. kaushikshome
    Replies:
    4
    Views:
    759
    kaushikshome
    Sep 10, 2006
  4. scad
    Replies:
    23
    Views:
    1,157
    Alf P. Steinbach
    May 17, 2009
  5. Giles Bowkett
    Replies:
    9
    Views:
    399
    Giles Bowkett
    Dec 17, 2007
Loading...

Share This Page