http://www.perlmonks.org?node_id=242991


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:

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