3 @ORIG_INC = (); # (avoid typo warning)
4 @ORIG_INC = @INC; # take a handy copy of 'original' value
15 my $mode = shift if $_[0] =~ m/^:[A-Z]+/;
18 foreach(@_) { ++$names{$_} };
20 if ($mode and $mode eq ':ALL') {
21 # Remove ALL instances of each named directory.
22 @INC = grep { !exists $names{$_} } @INC;
24 # Remove INITIAL instance(s) of each named directory.
25 @INC = grep { --$names{$_} < 0 } @INC;
33 lib - manipulate @INC at compile time
43 This is a small simple module which simplifies the manipulation of @INC
46 It is typically used to add extra directories to perl's search path so
47 that later C<use> or C<require> statements will find modules which are
48 not located on perl's default search path.
51 =head2 ADDING DIRECTORIES TO @INC
53 The parameters to C<use lib> are added to the start of the perl search
60 BEGIN { unshift(@INC, LIST) }
63 =head2 DELETING DIRECTORIES FROM @INC
65 You should normally only add directories to @INC. If you need to
66 delete directories from @INC take care to only delete those which you
67 added yourself or which you are certain are not needed by other modules
68 in your script. Other modules may have added directories which they
69 need for correct operation.
71 By default the C<no lib> statement deletes the I<first> instance of
72 each named directory from @INC. To delete multiple instances of the
73 same name from @INC you can specify the name multiple times.
75 To delete I<all> instances of I<all> the specified names from @INC you can
76 specify ':ALL' as the first parameter of C<no lib>. For example:
81 =head2 RESTORING ORIGINAL @INC
83 When the lib module is first loaded it records the current value of @INC
84 in an array C<@lib::ORIG_INC>. To restore @INC to that value you
87 @INC = @lib::ORIG_INC;
92 use lib @lib::ORIG_INC;
96 AddINC - optional module which deals with paths relative to the source file.
100 Tim Bunce, 2nd June 1995.