Your question had two parts -- neither of which is particularly a Perl question, but the second one at least a programming question. (For the first part, you'll want to take a look at your webserver's documentation. For dealing with security, you might want to take a look at suExec for apache, or cgiwrap for any other server.

Now -- for graphing -- I don't know exactly what you're trying to do, but overwriting the same file over and over again based on the input from the user just seems to be asking for trouble. If you have users A & B asking for the same page, but with different input, at almost the same time, it's possible that one of them will be given the wrong image. You also have to make sure to send the necessary cache-control headers in case the user tries revisiting the page with new parameters.

Instead, I see two main options:

  1. Give each image a unique name. The problem is, you need a routine to periodically go through and clean up the older images, so you don't fill your disk.
  2. Generate the images as they are requested. Images don't need to be static files ... they can be generated from CGIs as well. So, as you take the parameters from the user, you can then pass the relevent ones onto the image generating CGI, either through the QUERY_STRING, or PATH_INFO:

    <img src='/cgi-bin/script?param=value;param2=value2' alt='whatever' height='x' width='y'>
  3. The whole page will take a little longer to load, as you don't start generating the image 'till the image is requested, rather than the page being requested, but I find it to be easier to maintain, as you don't need to worry about temp directories. If you're worried about other people making use of the image generating routine, you can add some sort of checksum to the parameters passed in, so it's less likely that someone will bypass the first page.

Note -- I've made a possibly incorrect assumption that the images vary with the parameters passed in and some sort of internal state, and that each image generated is most likely to be unique, or at the very least repeat so infrequently as to be not worthwhile to cache. If this isn't the case, you'll need to provide more details about what you're trying to do.


In reply to Re: (OT) Regarding CGI script location by jhourcle
in thread (OT) Regarding CGI script location by cool

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.