Firstly, as mr nick observes, your best option is to exclude index.htm at the point where you read the directory, or whatever else is involved before you invoke this sub.

But then i'm a little confused, as this script won't try and read index.htm anyway. It appends .dat to the name you pass to it, so it I suppose it might try and read index.htm.dat if you're coming from an earlier readdir, but then it will just go &oops in the proper way.

Please reply if there's a particular problem i haven't understood, but it seems to me that you're basically fine.

Except there are much better ways to protect the directory from passers-by, anyway. A basic through-obscurity approach like this is pretty shaky, especially if the cats and ids are appearing on a site somewhere. The simplest alternative would be to put the data outside the web root, or use an .htaccess file to exclude everyone.

Your .htm suggests that you're on windows. I guess IIS must have some equivalent directory-level access-control mechanism? I tried looking on google but it kept offering me MCSE courses so i fled.


In reply to Re: Ignoring index.htm in a directory by thpfft
in thread Ignoring index.htm in a directory by SysAdm

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.