Devel-Deanonymize
view release on metacpan or search on metacpan
lib/Devel/Deanonymize.pm view on Meta::CPAN
if ($input =~ /^[\s]*(__END__|1;|1\Z|__DATA__)[\s]*$(.*)\Z/gms) {
return 1;
}
return 0;
}
sub modify_files {
# Internal notes:
# Basically, this code replaces every file path in @INC with a reference to an anonymous sub which wraps each
# file in sub classWrapper { $orig_content } classWrapper(); However, this sub is **not** necessarily run at INIT or UNITCHECK stage!
# NB, this also explains why its is possible to have $include_pattern "defined" at UNITCHECK even if its run **before** import()
# Also make sure each file either ends with __DATA__, __END__, or 1;
unshift @INC, sub {
my (undef, $filename) = @_;
return () if ($filename !~ /$include_pattern/);
if (my $found = (grep {-e $_} map {"$_/$filename"} grep {!ref} @INC)[0]) {
print "Devel::Deanonymize: $found" . "\n" if $ENV{DEANONYMIZE_DEBUG};
local $/ = undef;
open my $fh, '<', $found or die("Can't read module file $found\n");
my $module_text = <$fh>;
close $fh;
lib/Devel/Deanonymize.pm view on Meta::CPAN
};
}
# We call modify_files twice since depending on how a module is loaded (use or required) it is present in @INC at different stages
# Also, "double-modification" is not possible because we only alter non references
INIT {
modify_files();
}
UNITCHECK {
modify_files();
}
1;
( run in 1.415 second using v1.01-cache-2.11-cpan-748bfb374f4 )