why_bird has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks,

Just wondering what the deal is with invoking a shell script with

#!/bin/sh #-*- perl -*- exec perl -x $0 "$@"
Rather than the "usual" (or should that be "beginner"?) method:
In perlrun it says something about being sure that Perl can read your switches---is this the only reason?

I originally thought it had something to do with portability between systems, but now think that may not be true because some systems don't recognise the shebang line at all.. or does that not matter when you invoke it the first way?

Then I thought that it might be for people who keep their perl in weird places or who want to be able to switch between versions of perl easily. Is that right? It seems most plausible!

I've tried searching with Google, but it just ignores all special characters, so no luck there. (This annoys me a lot actually, that they don't have some facility for specfically including special characters in the search.. on a complete tangent does anyone know a search engine that does?? or is there a way to make Google behave as I want?)

Those are my principles. If you don't like them I have others.
-- Groucho Marx