require Data::Dumper;
Data::Dumper->import('Dumper');
The first part is done in your startup.pl.
The ->import(...) part is also only done in your startup.pl instead of (what you intend to) in every module.
The solution would be to either explicitly import it, to explicitly call it as Data::Dumper::Dumper( ... ), or to have one central module, App::Nysus::Utils(), which exports Data::Dumper::Dumper into every caller:
use App::Nysus::Utils; # import all the stuff
package App::Nysus::Utils;
use strict;
use Data::Dumper (); # just for completeness / offline testing outside
+ of Apache
sub import {
(my $target) = caller();
no strict 'refs';
*{ "$target\::Dumper" } = \&Data::Dumper::Dumper;
};
1;
I'm not sure which route I would go. They all have disadvantages and advantages:
- explicit import - makes everything explicit, allows for easy offline testing, clutters your source code
- explicit calling - makes everything even more explicit, doesn't allow for offline testing, clutters your source code even more
- utility module - keeps everything implicit, allows for easy offline testing, keeps your source code as is, but hides where stuff comes from
|