josh803316 has asked for the wisdom of the Perl Monks concerning the following question:

So I have a directory full of code files and I want to find the file(s) that contain a specific function name or string of text. What is the best way, using ack, to find these strings and also print out which files they are in and potentially line numbers as well.

something along the lines of:
cat * | ack "string to search for"

Replies are listed 'Best First'.
Re: using perl ack to find function names
by Your Mother (Archbishop) on Apr 09, 2010 at 21:00 UTC

    ack -- This is a very strange question. You must be overthinking it because you just type ack 'search string or regex'. The whole point of ack is that it searches code only by default and spits out files and line numbers.

    moow@cow[124]/> ack sub\ can inc/Module/Install/Can.pm 19:sub can_use { 33:sub can_run { 49:sub can_cc {
      Wow, yes I was overthinking it......thank you very much for that