http://www.perlmonks.org?node_id=11109880


in reply to Using perl module if env is enabled

See use. use Foo::Bar; is basically BEGIN { require Foo::Bar; }. If you want some conditional logic, you can put that into the BEGIN block as well:

BEGIN { if( $ENV{USE_XYZ}) { require Foo::Bar; Foo::Bar->import(); } }

The if module wraps that simple case already:

use if $ENV{USE_XYZ}, 'Foo::Bar';