There are really two concepts in Perl's packaging and namespace system that are intertwinned, and that seems to cause confusion.
The concepts are
1. where is the package? The @INC array is what Perl searches to locate your package
2. how is this package related to other packages? Some people believe that the 'use A::B::C;' notation indicates that C is a related to B, which is related to A, ala OO inheritance. This can be the case, but generally is not. Perl does not dicatate either way. More later.
For 1, you have a couple of options
a. put all the packages in one spot, and add that location to the @INC array.
b. make directories below an entry in @INC, and specify the directory path in the scripts/modules
Thus for a, you could have a directory off perl/lib called projectA, and in there you could put moduleA, moduleB,etc. Add perl/lib/projectA to @INC, then specify the module you need in your script as 'use moduleA;' etc
And for b, you leave @INC unchanged, but put 'use projectA::moduleA;' in your code.
So the 'use A::B::C;' in your scripts really only indicates the path below an @INC entry to search. It does not imply that if the code 'knows' where A::B is, it should be possible to just say 'use C;'. The module locating code in Perl will still complain.
For 2, how are modules related, Damian Conways quote is - I think Mark-Jason Dominus said it best when he pointd out that Newton::Isaac is not related to Newton::John::Olivia. - end quote
If you want to indicate that a module is 'related' to another, use the @ISA array
package Newton;
# methods and class attributes supported by all Newtons
...
sub be_famous {
}
package Issac;
# inherit things Newtons can do
@ISA qw(Newton);
# methods and class attributes supported by Newton::Issac instances
...
sub progress_physics {
}
package John;
@ISA qw(Newton);
# no methods/attributes, by themselves Newton::John's can just be famo
+us (inherited from Newton)
package Olivia;
@ISA qw(John);
# methods and class attributes supported by Newton::John::Olivia insta
+nces
...
sub sing_like_a_bird {
}
Each of these packages may or may not be OO, but the @ISA expresses a relationship when it comes to resolving method calls - for a fantastically crystal clear explanation see Damian Conways Object Oriented Perl by Manning (ISBN 1884777791) - ,but it does not dictate where the packages are, only @INC does that. In this case, you need to specify all the locations in @INC (if they are all in different directories) or make one addition to @INC, (if they are all in one directory), or make no changes to @INC, and put them all in a location in the standard @INC (not recommended, it is possible that you'll clobber a standard module that happens to have the same name as one of yours, or a CPAN module installation clobbers one of yours)
So remember, the 'use A::B::C;' just specifies the path below an @INC entry to search, not a relationship between A or B or C. They MAY BE related, but that is NOT determined by the use syntax. That is best done by @ISA, if an inheritance scheme is appropriate.
Setting @INC can be done in many ways, the most common is via 'use lib qw(... paths ...), or (my preferred way, stops coding of paths in scripts) by setting PERL5LIB in my shell ( if the platform supports the concept of a shell), or by manipulating @INC directly via
<code>
push @INC, $new_path; # add to back of search path
unshift @INC, $new_path; # add to front of search path
<\code>