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.


In reply to Re: Re: Re: Search string giving incorrect results by dws
in thread Search string giving incorrect results by Bishma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.