Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: regexp for finding all function calls

by marksman (Novice)
on Jul 17, 2009 at 21:16 UTC ( #781178=note: print w/ replies, xml ) Need Help??


in reply to regexp for finding all function calls

I think I figured out one way to do it:

my $res = $Doc->find ( sub { if ($_[1]->class eq 'PPI::Statement') { # find all PPI::Token::Words within the statement that have # literal equal to Mod::func # non-zero return means it found something $_[1]->find(sub { $_[1]->isa('PPI::Token::Word') and $_[1]->literal eq 'Mod::func'; }) } else {return 0;} } );
Update: Figured out the line numbers too
if ($res) { foreach (@$res) { my $line = @{$_->location}[0]; print "# line number: $line \n"; print "$_\n"; } }


Comment on Re: regexp for finding all function calls
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://781178]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2015-07-04 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls