[Pdx-pm] how to append to library path?

Joshua Keroes jkeroes at eli.net
Mon Dec 15 14:50:36 CST 2003

On (Mon, Dec 15 12:40), Chris Dawson wrote:
> Is it possible to append to the @INC path such that any instance of Perl 
> always uses a special library path?  Is this something that is compiled 
> into perl, or is there a file which I can modify to do this?  I realize 
> I can add a "use lib" statement to my scripts, but I would like to 
> enable this in a more global way.

To modify @INC globally, you'll need to rebuild perl.

@INC and module tricks:

List your default @INC, the one your perl was originally built with:
	perl -V

Prepend directories to @INC:
	use lib qw[ /path/to/somewhere/ ];
	use lib qw[ . .. ];

Append directories to @INC:
	BEGIN { push @INC, qw[ /path/to/somewhere ] }

Show loaded libraries and where they were loaded from:
	use Data::Dumper; print Dumper \%INC;

Hope that helps,

More information about the Pdx-pm-list mailing list