Created
June 19, 2020 04:41
-
-
Save exodist/f2975353a4639a52c09af1ceb79a6a90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Devel::Prof; | |
use strict; | |
use warnings; | |
our %files; | |
no warnings 'redefine'; | |
our $on; | |
BEGIN { $on = 1 }; | |
sub off { $on = 0 }; | |
# uncommenting this causes the main script to say Dumper is not defined. | |
#sub DB::sub { | |
# return unless $on; | |
# my ($pkg, $file) = caller(0); | |
# $Devel::Prof::files{$file}++; | |
# return; | |
#}; | |
sub DB::DB { | |
return unless $on; | |
my ($pkg, $file, $line, $sub) = caller(0); | |
$Devel::Prof::files{$file}++; | |
return; | |
} | |
sub files { \%files } | |
1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
perl -Ilib -d:Prof yyy.pl | |
$VAR1 = { | |
'lib/Devel/Prof.pm' => 1, | |
'yyy.pl' => 7 | |
}; | |
# If I uncomment sub DB::sub | |
perl -Ilib -d:Prof yyy.pl | |
Use of uninitialized value $file in hash element at lib/Devel/Prof.pm line 18. | |
Use of uninitialized value $file in hash element at lib/Devel/Prof.pm line 18. | |
Use of uninitialized value $file in hash element at lib/Devel/Prof.pm line 18. | |
Undefined subroutine &main::Dumper called at yyy.pl line 14. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Data::Dumper; | |
use YYY; | |
sub Bar { eval { Foo::Bar() } } | |
sub Foo::Bar { Foo::Bar::Bar() } | |
sub Foo::Bar::Bar { sub { 'BAR' }->() } | |
Bar(); | |
Devel::Prof->off(); | |
local $Data::Dumper::Sortkeys = 1; | |
print Dumper(Devel::Prof->files); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use XXX; | |
sub xxx { 1 }; | |
xxx(); | |
sub import { 1 } | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment