In order to avoid problems with syntax validation (such as packages reported missing) and the debugger (such as skipped breakpoints), it is best to organize your project according to the conventions of the core Perl distribution:
-
Keep your own modules in dedicated subtrees of your project. For example, create a subdirectory
libas the root of the subtree containing all *.pm files. Note that you can have more than one such subtree. For example, you could also createtest/libto store modules that are only imported by test scripts. -
Add the root directories of your subtrees to the @INC path (see the section called “Perl Include Path”). For example, add the entries
libandtest/libthere. -
Map package names to paths in the subtree (and vice versa). For example, store code for the package
Foo::Barin filelib/Foo/Bar.pmand ensure thatlib/Foo/Baz.pmcontains only packageFoo::Baz. -
Store your Perl scripts anywhere you like in the project. For example, in subdirectory
binorcgi-bin. -
To import from a package,
useit, rather thanrequireit. For example,use Foo::Bar;rather thanrequire '../lib/Foo/Bar.pm';