SPUG: add to default @INC

David Dyck david.dyck at fluke.com
Fri Jul 18 16:20:39 CDT 2003

On Fri, 18 Jul 2003 at 14:05 -0700, Brian Wisti <brian at coolnamehere.com> wrote:

> There's a few tricks.
>     $ perl -I/path/to/added/directory
>     $ export PERL5LIB="/path/to/added/directory:$PERL5LIB"
> You can also use the 'use lib' pragma, but that's a runtime
> modification, so it doesn't sound like what you're looking for.  Of all
> of the options, setting the PERL5LIB environment variable seems like the
> closest to what you are asking for.  Of course, this _is_ Perl, so there
> are probably other tricks as well :-)

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);
    return 1;

More information about the spug-list mailing list