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:
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.use strict; use warnings; require Data::Dumper; local $Data::Dumper::Indent = 0;
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:
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 ...$Data::Dumper::Indent = $Data::Dumper::Indent;
Back to
Seekers of Perl Wisdom