Two primary methods immediately come to mind: Assuming you have a scheduling means, I would say the second is the better method -- something isn't always running (your efficiency concern), and it's more robust becuase you don't have to worry about the job getting hung or killed.

Two methods pop to mind for the actual "checking" part, too:
Be sure to reference the File::Find module as well as the -X and stat sections in the perlfunc manpage.

Update: Here's an actual one-liner solution i used out of a linux crontab once (convenient cause cron takes care of emailing you iff there's output)--this is the shell script wrapping it (I don't necessarily recommend this, but might have some reference value):
# USAGE: touchedCheck filename [minutes] # # Exit Value: 0 if file was touched; 1 if not touched. # # Will print info about the file iff it changed in the last N minutes. # Otherwise prints nothing. # # Intended for crontab use, such as: # 0 * * * * touchedCheck /tmp/some_file.txt 60 # /usr/bin/perl -e '$f=shift;$N=shift||60; printf("%s was changed %d min +utes ago.\n%s", $f, $x/60.0, `/bin/ls -lart $f`) && exit(0) if ($x = +(time - (stat($f))[9])) <= 60*$N; exit(1)' $1 $2

In reply to Re: starting a script when a file appears in a directory by davidrw
in thread starting a script when a file appears in a directory by Mattk470

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.