in reply to Recursively grep through directory trees.

Nice code. I do have a couple of suggestions tho'.

  1. Instead of if (-d) {} why not just use return if -d;
  2. You use the variable $count to keep track of the current line number, but Perl already does that for you in the $. variable

Hope these are helpful.

--
<http://www.dave.org.uk>

European Perl Conference - Sept 22/24 2000, ICA, London
<http://www.yapc.org/Europe/>
  • Comment on RE: Recursively grep through directory trees.

Replies are listed 'Best First'.
RE: RE: Recursively grep through directory trees.
by Melvin (Beadle) on Jul 12, 2000 at 17:33 UTC
    Thanks for the tips! I've modified the above snippet, including your suggestions, as well as added a few regex's to strip out initial whitespace, as well as added the ability to specify a file extension (actually, a file pattern match).

    For example, I just used "grep checkbox php" to grep all php files for a checkbox.