Using the env Program
The magic string method is non-portable. If the perl command is moved to another location or the script is used on another machine, the script will not work.
A solution to this problem is to use the helper program env. This involves putting a new magic string at the top of our script:
When the script is run, the env program starts up. Its job is to look at the rest of the command line and run the command specified. So in this case, the first perl in your path will be executed.
Advantages of the env approach include:
The disadvantages are:
Won't work for setuid scripts
Won't work if the perl command is not in your path