Skip to content

Instantly share code, notes, and snippets.

@ChinaXing
Created August 8, 2013 09:53
Show Gist options
  • Save ChinaXing/6183318 to your computer and use it in GitHub Desktop.
Save ChinaXing/6183318 to your computer and use it in GitHub Desktop.
use B find out FILE and LINE of reference
# ----------- 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