in reply to Re: Re: Search string giving incorrect results
in thread Search string giving incorrect results

This code has a couple of problems. One is that the handling of filenames, particularly the method of extracting a number from them, is highly suspect. Once you think you've extracted $number, try printing both the full filename and $number.

It looks like you're trying to accumulate a list of thread nubmers that contain matches. Since you say that $thread_data[0] is the same as $number, this might be easier like so:

my @dat_files = <$bboard/*.dat>; my %found = (); foreach my $file ( @dat_files ) { open(DAT, $file) or die "$file: $!"; while ( <DAT> ) { my @thread_data = split "|"; if ( $thread_data[4] =~ m/\Q$in{$for}\E/i ) { $found{$thread_data[0]}++; } } close(DAT); }
The keys of %found are now the thread numbers taht contain a match, and the corresponding values are the number of matches.