http://qs321.pair.com?node_id=11139324

karlberry has asked for the wisdom of the Perl Monks concerning the following question:

Occasionally I want to "require" a module, rather than "use" it (to avoid loading it at compile-time) and still "use strict". What is the best way to handle variable references into the module? My example:
use strict; use warnings; require Data::Dumper; local $Data::Dumper::Indent = 0;
yields Name "Data::Dumper::Indent" used only once: possible typo. I am not surprised by the warning, require happening at runtime and all; the question is how to get rid of it.

Clearly "use vars" and "our" do not help, since they don't take variable names in another module. Specifying "no warnings 'once'" works, but I don't want to turn off these warnings in general, just because I want to set a module's configuration variable.

The only way I have found to avoid the warning is to add some additional null usage, as in:

$Data::Dumper::Indent = $Data::Dumper::Indent;
This does not seem like it should be necessary. I feel like I'm missing something obvious, but I'm failing to discern the answer. Documentation reading and web searches have not been successful. Thanks for any info ...