App-FindCallers

 view release on metacpan or  search on metacpan

lib/App/FindCallers.pm  view on Meta::CPAN

    my $location = $filename . ":" . $f->line_number;

    printf "%s%s %s() in %s\n", $indent, $message, $f->name, $location;
}

sub find_in_file {
    my ($function, $filename, $cb) = @_;
    $cb ||= \&report;
    my $document = PPI::Document->new($filename);
    unless ($document) {
        say "Failed to parse $filename " . PPI::Document->errstr;
        return;
    }
    $document->index_locations;
    my $references = $document->find(sub {
        $_[1]->isa('PPI::Token::Word') and $_[1]->content eq $function
    });
    return unless $references;
    for my $f (@$references) {
        my $nestlevel = 0;
        while ($f = $f->parent) {



( run in 1.088 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )