Specifying multiple perl interpreters for a script

Y

Yash

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
 
M

mr.happy

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.
 
P

Peter Scott

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top