Some comments:

opendir(DIRE, "/home/lenn287/public_html/diary"); my @files_exist = reverse sort map { $_ =~ s/^(\d+)\.html$/$1/; $_} grep { /^\w+.\.html$/} readdir DIRE; closedir DIRE;

Here your first regexp checks for (\w) and the second matches digits, so if you have a file called "bleh.html" it will pass the first grep but it will produce an empty entry on the display. Change the \w+ into \d+.

open my $FH,'<', '/home/lenn287/public_html/diary/'.$file_name.".html" +;

You don't check if your open succeeded or not.

for($first_file; $first_file<=$last_file;$first_file++) {

Since you're coding Perl:

for my $f ($first_file .. $last_file) {

On another note, since you want to search within the files, you should either create an index of some sorts, instead of opening each file and searching, or use a database to store the contents and then you can use fulltext search on them.

just a couple of cents

--
Leviathan.

In reply to Re: Need advices, displaying files in directory with CGI.. by Leviathan
in thread Need advices, displaying files in directory with CGI.. by doctor_moron

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.