use blib

From the command line:

% perl -Mblib program [args…]
% perl -Mblib=DIR program [args…]

From your Perl program:

use blib; 
use blib 'DIR';

This pragma is intended primarily as a way of testing arbitrary Perl programs against an uninstalled version of a package through Perl's -M command-line switch. It assumes your directory structure was produced by the standard ExtUtils::MakeMaker module.

The pragma looks for a blib directory structure starting in the directory named DIR (or current directory if none was specified), and if it doesn't find a blib directory there, works its way back up through your ".." directories, scanning up to five levels of parent directory.

Get Programming Perl, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.