I thought this would be an easy thing but I am having major toubles with it. I am basically trying to create a search engine that will search a specified directory, return all the files in it, and search each file for the matching text. This is for a CGI script by the way.
if ($com eq "Submit Search") { opendir (TEMP, 'po'); @files = readdir(TEMP); foreach $file (@files) { open(FILE,"po/$file") || die "can't open "; $filein = <FILE>; close (FILE); # $filein =~ s/,/ /g; if (-d $file) {} elsif ($search =~ /$filein/i) { print "<a href=\"index.cgi?file=$file\">$file</a> +<br><br>"; } else {print "<br>File not Found<br>"; } } }
i am having trouble with the elsif ($search =~  /$filein/i) { part. $filein is a CSV file that looks something like this:
D04101,4/10/01,4,30,01,James Bernard,PO Box 4623,Chicago,IL,60680-4623 +,773-379-9873,,,Self-Inking Stamp Red
So if i search for "james", it comes up as "file not found" even though "james" is clearly in the file. But The File will be found if all it has in it is the word "james". Am i totally missing something. I hope you all can understand what i am looking for. Thanks Elton

In reply to trying to create search engine by elton247

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.