B::Source - Indexes your perl source code by filename and COP
use B::Source; use Data::Dumper; $Data::Dumper::Sortkey = 1; print Dumper( index_source->{$0} );
This module attempts to find all of the subroutines currently in memory and then index their source code by their COP nodes from their optrees. The idea is that when given a B::COP object you can now look up its related source code through its ->line and ->file properties.
This module was written to support B::Deobfuscate and B::ToXML and isn't something I'd normally consider using directly.
This takes no parameters and returns a hash reference. The keys are your source file names from the B::COP objects. The values are hashes of line numbers and source code. A B::COP object's ->file and ->line properties are keys to the source code.
{ 'foo.pl' => { '1' => 'use strict', '5' => 'print 1' }, 'bar.pm' => { ... } }
Joshua b. Jore <jjore@cpan.org>