If you use sudo, CPAN will use root to install the libraries in a central location where all users on the machine can access the files without any special configuration. If you use 'local::lib', it will create a library in your home directory and install the modules such that only perl programs that have been configured to look for modules in your home directory will find the modules.
Perl uses the special variable @INC
to search for module paths. So you can install modules anywhere as long as you set @INC
properly before you use them. This article explains the basics.
http://www.symkat.com/find-a-perl-modules-path
You can do all kinds of fun stuff with @INC
; one of my favorite hacks it to put a function pointer in there and use custom perl code to lookup modules.