[comp.lang.perl] using #! for perl scripts

frazier@oahu.cs.ucla.edu (Greg Frazier) (05/17/91)

rusty@groan.Berkeley.EDU (Rusty Wright) writes:

>The man page for execve says that the pathname given after the #! can
>be at most 32 characters.  But the full pathname of perl on my machine
>is more than 32 characters.  Does anybody have recommendations on a
>good consistent way to deal with this?

I don't know if it's good, but you can create a local symbolic
link to perl.
-- 


Greg Frazier	frazier@CS.UCLA.EDU	!{ucbvax,rutgers}!ucla-cs!frazier

rusty@groan.Berkeley.EDU (Rusty Wright) (05/17/91)

The man page for execve says that the pathname given after the #! can
be at most 32 characters.  But the full pathname of perl on my machine
is more than 32 characters.  Does anybody have recommendations on a
good consistent way to deal with this?

tchrist@convex.COM (Tom Christiansen) (05/18/91)

From the keyboard of rusty@groan.Berkeley.EDU (Rusty Wright):
:The man page for execve says that the pathname given after the #! can
:be at most 32 characters.  But the full pathname of perl on my machine
:is more than 32 characters.  Does anybody have recommendations on a
:good consistent way to deal with this?

You can make sh start it, then exec your own perl:

	    
    #!/bin/sh  # need to mention perl here to avoid recursion
    #
    #
    # NOTE:
    #   If you know where perl is and your system groks #!, put its
    # pathname at the top to make this a tad faster.
    #
    # The following magic is from the perl man page
    # and should work to get us to run with perl
    # even if invoked as an sh or csh or foosh script.
    # Notice we don't use full path 'cause we don't
    # know where the user has put perl on their system.
    #
    eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
	if $running_under_some_stupid_shell_instead_of_perl;


--tom
--
Tom Christiansen		tchrist@convex.com	convex!tchrist
		"So much mail, so little time."