One possibility is to delete old files at the beginning of the script. When your script is executed by the web server, it could first delete all its images files that are older than 5 minutes, and then create a new image file. The five minute period is important in case your script is run by more than one user at the same time. Here's a quick example:
my $time = time; my $image_dir = '/path/to/script\'s/private/image/dir'; opendir(DIR, $image_dir) or die "Can't opendir $image_dir: $!\n"; while (defined(my $filename = readdir(DIR))) { next unless -f "$image_dir/$filename"; next unless time - (stat(_))[9] > 300; unlink("$image_dir/$filename") or warn "Can't unlink $image_dir/$filename: $!\n"; }

In reply to Re: deleting a file after loading by chipmunk
in thread deleting a file after loading by belize

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.