File-SafeDO
view release on metacpan or search on metacpan
return undef if eval q|system($_, '-Mwarnings', "-M-warnings qw($nowarnings)", $file)|;
} else {
return undef if eval q|system($_, '-w', $file)|;
}
# poke anonymous subroutine into calling package so vars and subs will import
my $caller = caller;
# execute 'do $file;' in calling package
&{eval "package $caller; sub { my \$file = shift; do \$file;};";}($file);
}
sub DO($;$) {
my($file,$nowarnings) = @_;
my $caller = caller;
@_ = ($file,$nowarnings,$caller,0);
goto &_doFILE;
}
=item * $rv = doINCLUDE($file,[optional] "no warnings string");
The function is similar to B<DO> above with the addition of recursive loads.
( run in 0.744 second using v1.01-cache-2.11-cpan-5b529ec07f3 )