Greetings, I'm trying to discover if I can give a temporary file a "Life Span"
in Perl. Is such a thing even possible? My sutuation:
I'm generating a symlink (perlfunc=>symlink) that prefaces a semi-random
number to the $filehandle, thusly:
#!/usr/bin/perl -wT # testing with a web browser print "Content-type: text/html\n\n"; use strict; use POSIX qw(strftime); my $gmtstring = strftime "%H-%I-%S", localtime; my $filehandle = "relative/path/to/filename"; my $dir = "." if (-r $filehandle) { $filehandle = "readable"; }else{ $filehandle = "unreadable"; } if (-w $dir) { $dir = "writable"; }else{ $dir = "unwritable"; } unless ($filehandle && $dir) { symlink("$filehandle", "$gmtstring-$filehandle") }else{ print "$filehandle<br />$dir"; }
This much returns the anticipated/expected results. However,
I want the newly created symlink to "vanish" (perlfunc=>unlink)
after --say, a 10 minute period. Is there ANY way to tell Perl to unlink
the symlink -- like creating a timer, or something? I'm not sure where to go with
this. I could create a cronjob. But I would really rather keep
this "self-contained" if it's even remotely possible.

Thank you for all your time, and consideration.

--chris

UPDATE It also occurred to me that a session || sessions, might also be a solution.
In the "big picture" these "temporary" symlink(s), are largish files of complete systems for
embedded systems. I only want them to become available for those that actually want to use them --
not to embellish other ppl's web pages, and for "bots" to suck down ~50 times/day. So
it occurs to me that the "Life Span" of the file could be tied to a session.
Is that possible, or a better approach?

Thanks again.

#!/usr/bin/perl -Tw
use perl::always;
my $perl_version = "5.12.4";
print $perl_version;

In reply to Temporary file management in Perl -- is it possible? by taint

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.