SPUG: add to default @INC

Brian Hatch spug at ifokr.org
Fri Jul 18 17:03:40 CDT 2003



> I'm sure that PERL5LIB is what you want, but the mention of "runtime"
> mods reminded me of some working code that I use to modify @INC
> and load a module before starting up the wrapped perl.
> 
> #include <stdio.h>
> #include <unistd.h>
> 
> int main(int argc, char **argv)
> {
>     int i;
>     char *myargv[argc+3];
> 
>     myargv[0] = "pktperl";
>     myargv[1] = "-I/home/hobbes/tools/perl5";
>     myargv[2] = "-I/home/hobbes/tools/scripts";
>     myargv[3] = "-MPktperl";
>     for (i=1; i<argc; i++) {
>         myargv[i+3] = argv[i];
>     }
>     myargv[argc+3] = 0;
>     execvp("perl", myargv);
>     perror("execvp");
>     return 1;
> }

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.
;-)

(I like the idea of preprocessing perl with perl...)


Of course your scripts would need to use

	#!/usr/bin/perlwrapper

instead of 

	#!/usr/bin/perl

--
Brian Hatch                  The trouble with life
   Systems and               is there's no background music.
   Security Engineer
http://www.ifokr.org/bri/

Every message PGP signed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/spug-list/attachments/20030718/e8c01f46/attachment.bin


More information about the spug-list mailing list