Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: regexp for finding all function calls

by Fletch (Chancellor)
on Jul 07, 2009 at 21:47 UTC ( #778032=note: print w/ replies, xml ) Need Help??


in reply to regexp for finding all function calls

Sounds like an XY Problem. Step back and explain what you're attempting to accomplish and there may be a better approach (e.g. using B::Xref and post-processing its output).

The cake is a lie.
The cake is a lie.
The cake is a lie.


Comment on Re: regexp for finding all function calls
Re^2: regexp for finding all function calls
by Anonymous Monk on Jul 07, 2009 at 22:07 UTC
    Ok.

    I have a large code base of say thousands of perl files. I want to copy all calls to Mod::func() interspersed in these thousands of files to a single file, say funcCalls.pl. Then I will run fucCalls.pl and verify the output of all of the calls to Mod::func().

    If the output is wrong, hopefully I will have recorded the line number and file from which each call to Mod::func() came from. In this way I will be able to fix any erroneous calls to to Mod::func().
      I'd recommend using PPI, which does its best (and a very good job) at actually parsing Perl. You can search through the parse tree for sub calls, and check their names.

      That will be much more accurate than anything you can achieve with a regex.

        Ok, thanks.

        Do you have any good examples for me to look at? Would I be using PPI::Statement::Expression?
      By the way, that was my post above as Anonymous Monk, I forgot that I wasn't logged in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (15)
As of 2014-09-22 18:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls