Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: regexp for finding all function calls

by Anonymous Monk
on Jul 07, 2009 at 22:07 UTC ( #778036=note: print w/replies, xml ) Need Help??

in reply to Re: regexp for finding all function calls
in thread regexp for finding all function calls


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 Then I will run 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().
  • Comment on Re^2: regexp for finding all function calls

Replies are listed 'Best First'.
Re^3: regexp for finding all function calls
by moritz (Cardinal) on Jul 07, 2009 at 22:28 UTC
    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?
        I haven't done much with PPI, but I know that Perl::Critic uses it extensively, so in the source code you'll find many usage examples.

        There are also some examples exaxmples here on perlmonks. Searching helps.

Re^3: regexp for finding all function calls
by marksman (Novice) on Jul 07, 2009 at 22:29 UTC
    By the way, that was my post above as Anonymous Monk, I forgot that I wasn't logged in.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://778036]
[GotToBTru]: it was approved . but isnt now
[GotToBTru]: ah nevermind .. i was looking at one of 2
[GotToBTru]: SOPW version still shows approved by choroba

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2017-01-16 15:17 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.