Created
August 8, 2013 09:53
-
-
Save ChinaXing/6183318 to your computer and use it in GitHub Desktop.
use B find out FILE and LINE of reference
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 B ---------------- # | |
# B is perl compiler backend | |
require B; | |
my $ref = sub { | |
print "Hello, world !\n"; | |
}; | |
my $gv = B::svref_2object($ref)->GV; | |
print 'variable $ref at :', $gv->LINE, ' line of file ', $gv->FILE, "\n"; | |
__END__ | |
# -------------- result -------------- # | |
=begin result | |
variable $ref at :7 line of file tp.pl | |
=end result | |
=cut |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment