I tend to use Data::Dumper very often, and I end up having the following boilerplate at the top of every package in my .pl code.
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Deparse = 1;
$Data::Dumper::Purity = 1;
Is there a way to specify that "inside the current .pl file, I want these statements to automatically assumed."
eg I would have
package foo;
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Deparse = 1;
$Data::Dumper::Purity = 1;
my @localState = (1, 2, 3, 4, 5);
sub test {
print Dumper \@localState;
}
package main;
use strict;
use warnings;
use Data::Dumper;
$Data::Dumper::Deparse = 1;
$Data::Dumper::Purity = 1;
foo->test;
this can quickly get way too much boilerplate repetition and harm maintainability.
Sadly I can't use a function with "eval" in it to call all this boilerplate since that boilerplate would be placed into the function, not global scope; Perl does not have Lisp macros that I know of to actually have non-function bound eval-like bahavior(I could be wrong, would be so cool if Perl had lisp macros).
Does anyone know if this behavior can be achieved without writing a parser to insert the statements in for me if it is the first package being declared inside file?