local $ENV{BLAH} = 42; libcall(); sub libcall { if( exists $ENV{BLAH} ) { print "env set to $ENV{BLAH}\n"; } else { print "env not set\n"; } } #### if( condition() ) { local $ENV{BLAH} = 42; } libcall(); #### if( condition() ) { local $ENV{BLAH} = 42; libcall(); } else { libcall(); }