in reply to Re: searching several files for a string at one time
in thread searching several files for a string at one time

glob and grep complement each other. glob is for finding filesystem entries (think "names"), and grep is for searching lists (like lines in a file). If you don't use the grep command line utility, then your Perl program will need to combine both. Use bsd_glob to find the files that are of interest, and then use grep to find the lines in those files.

Replies are listed 'Best First'.
Re^3: searching several files for a string at one time
by daggy (Novice) on May 06, 2010 at 11:33 UTC
    So the correct procedure would be to ask the user to specify the directory they wish to search in

    Use Glob to list all files in the directory? Or should I use glob to search for 'monk' and glob would bring back a list of files with 'monk' in them?

    then use Grep to specify which lines the word 'monk' is on?

    What is bsd_glob..

    Sorry for the completely noob like comments, but I'm a complete noob so it's to be expected.

      See File::Glob for bsd_glob. It is much like glob but has sane whitespace handling.

      You don't have to ask the user for the search term. See perlvar on @ARGV to see how you can retrieve the command line arguments that were given to your script.