RE: searching a file for keywords

2004-04-19 Thread Beckett Richard-qswi266
> I thought this would do the trick: > > if($wholefile =~ /^\s*$keyword\s*$/) This could be a \n issue. Do you chomp $wholefile before the match? If you don't want to chomp it, then try: if ($wholefile =~ /^\s&$keyword\s*\n$/) > This works, but is not as specific as I would like: > >

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 als

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 a

searching a file for keywords

2004-04-15 Thread Martin Leese
Craig Cardimon <[EMAIL PROTECTED]> 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