Re: searching a file for keywords

2004-04-15 Thread michael higgins
Craig Cardimon wrote: I'm searching a text file for keywords. These keywords are stored in an array. First, I read the file into a scalar variable. Then, I search for each keyword, cycling through the array in an outer foreach loop: foreach $keyword (@keywords) The keywords should be in all caps

Re: searching a file for keywords

2004-04-15 Thread Andy_Bach
You might do better to make an altenation: $keywords = join(|, @keywords); if ( $wholefile =~ /^\s*($keywords)\s*$/mo ) { # do you want 'i' ? rather than the loop. Worth a benchmark, but one search for multiple matches is probably faster than multiple searches for some sized files. You also