Specifying multiple perl interpreters for a script

Discussion in 'Perl Misc' started by Yash, Jul 13, 2004.

  1. Yash

    Yash Guest

    In our perl scripts, we give the path to the perl interpreter on the
    first line of the script as :
    #!/usr/bin/perl

    But our customers sometimes have perl installed in some other place
    such as /opt/perl/bin/perl or /usr/local/bin/perl

    Is there a way to specify all such possible paths and make sure the
    one that exists gets used?

    This is so that no change needs to be done at the customer's end.

    Thanks
     
    Yash, Jul 13, 2004
    #1
    1. Advertising

  2. Yash

    mr.happy Guest

    On Tue, 13 Jul 2004 06:39:11 -0700, Yash wrote:

    > But our customers sometimes have perl installed in some other place such
    > as /opt/perl/bin/perl or /usr/local/bin/perl
    >
    > Is there a way to specify all such possible paths and make sure the one
    > that exists gets used?


    'env' can be used for this:

    env(1) is often used with the #!-mechanism to start an interpreter, which
    then only needs to be somewhere in your PATH, e.g. "#!/usr/bin/env perl".

    However, env(1) is not /usr/bin/env but /bin/env on OpenServer 5 and on a
    very few Linux older distributions. Free-, Net- and OpenBSD in turn only
    come with /usr/bin/env. So the env-mechanism is increasing convenience,
    but not really assuring portability.

    http://www.in-ulm.de/~mascheck/various/shebang/

    greets,
    -- dirk
    You will be run over by a beer truck.
     
    mr.happy, Jul 13, 2004
    #2
    1. Advertising

  3. Yash

    svenne Guest

    Yash wrote:

    > #!/usr/bin/perl

    remove the path in the shebang line and add the path to your PATH env var.
    /G
    --
    --
    www.gh-webinteractive.com
     
    svenne, Jul 13, 2004
    #3
  4. Yash

    Peter Scott Guest

    In article <>,
    (Yash) writes:
    >In our perl scripts, we give the path to the perl interpreter on the
    >first line of the script as :
    >#!/usr/bin/perl
    >
    >But our customers sometimes have perl installed in some other place
    >such as /opt/perl/bin/perl or /usr/local/bin/perl
    >
    >Is there a way to specify all such possible paths and make sure the
    >one that exists gets used?


    If you subscribe to The Perl Journal, you'll find an article in
    the April 2003 issue (http://www.tpj.com/archives/0304/) covering
    exactly that. The mother of all shebang lines, you might say.

    --
    Peter Scott
    http://www.perldebugged.com/
    *** NEW *** http://www.perlmedic.com/
     
    Peter Scott, Jul 14, 2004
    #4
    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. Maciej Sobczak

    Multiple interpreters in a single process

    Maciej Sobczak, Jan 5, 2004, in forum: Python
    Replies:
    1
    Views:
    413
  2. Paul Miller
    Replies:
    4
    Views:
    331
    Paul Miller
    Jan 23, 2004
  3. bmatt
    Replies:
    2
    Views:
    325
    Frithiof Andreas Jensen
    Sep 29, 2004
  4. Replies:
    0
    Views:
    270
  5. vishnu
    Replies:
    0
    Views:
    394
    vishnu
    Mar 31, 2007
Loading...

Share This Page