#/usr/bin/perl for my $tree ("a","b") { local $ENV{PERL5LIB} = $tree; system("perl -e 'use Foo;Foo::Bar()'"); }