So far, the examples have glossed over how we've set up the directory structure of where the main code and the included files are located. That's because it "just works" for the simplest case where we have a program and its libraries in the same directory and we run the program from that directory.
Things get a bit more complicated when the libraries aren't in the
current directory. In fact, Perl searches for libraries along a library search path, similar to what the shell
does with the
variable. The current directory (represented in Unix by a single dot) is
an element of the search path. So, as long as our libraries are in our
current working directory, everything is fine.
The search path is a list of elements in the special
@INC array, as we briefly discussed in Chapter 3. By default, the array
contains the current directory and a half-dozen or so directories
specified by the person who compiled Perl. Typing
perl -V on the command line shows what these
directories are, in the last dozen lines of the output. Also, the
following command displays just the
perl -le 'print for @INC'
. in that list, we
probably won't be able to write to any of the other directories unless
we're the person responsible for maintaining Perl on our machine, in
which case, we should be able to write to all of them. The remaining
directories are where Perl searches for system-wide libraries and
modules, as we'll see later.
We may ...