use strict; use warnings; use Path::Tiny; use Test::More tests => 3; chdir '/'; # In case you have . in @INC my $mod = path ('/tmp')->child ('ZZZZZ.pm'); $mod->spew ('package ZZZZZ;1;'); ok ! system ("PERL5LIB=/tmp:/foo perl -e 'use ZZZZZ;'"), 'First in path'; ok ! system ("PERL5LIB=/foo:/tmp perl -e 'use ZZZZZ;'"), 'Second in path'; ok system ("PERL5LIB=/foo:/bar perl -e 'use ZZZZZ;'"), 'Not in path'; $mod->remove;