Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: #!$var/bin/perl

by hawtin (Prior)
on Mar 14, 2003 at 10:04 UTC ( #242991=note: print w/replies, xml ) Need Help??

in reply to #!$var/bin/perl

One option that I haven't yet seen mentioned is the /bin/env trick. If your first line is

#!/bin/env perl

The system will find the perl on your path and use that. This trick was used quite a lot when standard installations did not include Perl since it allowed "non-root" users to install local copies of Perl. It allows the different systems to have different locations for the perl installation and manages to work out everything for you.

The only difficulties are:

  • Security (already covered)
  • Some *NIX systems put the env program somewhere other than /bin (/usr/bin/env is quite common, you could add a symbolic link on those machines?)

Having something that modifies your scripts for different locations is often a bad idea (one of the great things about Perl is that it is portable). When distributing scripts you really don't want to have to edit the script to make it function (like when sending to naïve users).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://242991]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2016-10-27 23:31 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (372 votes). Check out past polls.