[alt.sources] Using perl without "#!"

chip@ateng.UUCP (Chip Salzenberg) (02/10/88)

Larry Wall's "perl" program is a real gem.  It is, unfortunately, also
difficult to use on systems without the "#!" hack for scripts.  (This is
one case where Berzerkeley Unix has the edge.  :-])

So, here is a way to fake it without "#!":  use one of the commands that
is the same under sh and perl: "eval".  Put this at the top of each perl
script:

	eval "exec /bin/perl $0 $*"
		if (0);

So when sh sees the first line, it executes it; then when perl sees it,
it passes the syntax check, but the if(0) keeps it from being executed.
-- 
Chip Salzenberg                 UUCP: "{codas,uunet}!ateng!chip"
A T Engineering                 My employer's opinions are a trade secret.
       "Anything that works is better than anything that doesn't."