SPUG: add to default @INC

David Dyck david.dyck at fluke.com
Fri Jul 18 18:00:45 CDT 2003


On Fri, 18 Jul 2003 at 15:03 -0700, Brian Hatch <spug at ifokr.org> wrote:

> Which could be done much cleaner with
>
> 	$ cat perlwrapper
> 	#!/usr/bin/perl
>
> 	exec /usr/bin/perl, qw( -I/home/hobbes/tools/perl5
> 		-I/home/hobbes/tools/scripts -MPktperl), @ARGV;
> 	exit 1;
>
> And then you don't need to scare people with C code on a Perl list.
> ;-)

> Of course your scripts would need to use
> 	#!/usr/bin/perlwrapper
> instead of
> 	#!/usr/bin/perl

(perlwrapper would be cleaner if it had
 quotes around "/usr/bin/perl" so it to compile :-)

One thing that perl does, that perl scripts can't do is act as an
"#!" interpreter, and I needed my "wrapper" to behave like perl enough
that it could be treated as an interpreter, so I could call it as you
suggested with #!.  The only way to do this is with a C wrapper, since
an script that uses an interpreter (like perl or my pktperl) can't be
a script itself!

from man execve:

       execve() executes the  program  pointed  to  by  filename.
       filename  must  be either a binary executable, or a script
       starting with a line of the form "#!  interpreter  [arg]".
       In  the latter case, the interpreter must be a valid path-
       name for an executable which is not itself a script, which
       will be invoked as interpreter [arg] filename.




More information about the spug-list mailing list