Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: determine the name of a function that contains a specified string

by moritz (Cardinal)
on Mar 30, 2012 at 11:33 UTC ( [id://962577]=note: print w/replies, xml ) Need Help??


in reply to determine the name of a function that contains a specified string

One approach is to just read the whole file into a scalar, search for the desired command, then extract everything up to that command into a second string, and search for the last function definition inside that second string.

Another approach is to read the file line by line, and when a match is found, open a second handle to that file, this time reading backwards (either File::ReadBackwards or PerlIO::reverse), seek to the position of the find, and then read (backwards) until the function definition is found.

A third approach is to read the file in function chunks straight away, and then search each chunk for the commands.

  • Comment on Re: determine the name of a function that contains a specified string

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-24 10:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found