[Israel.pm] How to detect a new file in a directory without busy wait ?
Yossi Itzkovich
Yossi.Itzkovich at ecitele.com
Thu Mar 27 12:36:18 EET 2008
Tal,
I work on Solaris. Isn't there a portable module around ?
Yossi
-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il] On
Behalf Of Tal Kelrich
Sent: Thursday, March 27, 2008 12:29 PM
To: perl at perl.org.il
Subject: Re: [Israel.pm] How to detect a new file in a directory without
busy wait ?
On Thu, 27 Mar 2008 11:50:35 +0200
Yossi Itzkovich <Yossi.Itzkovich at ecitele.com> wrote:
> Hi,
>
> I have a script that should wait for a new file to be created, and
> then start processing it. I don't know the filename, just the pattern
> (known prefix). I can do it like this
>
> While (1)
> {
> get directory content
> check each file for filename pattern. If found - last.
> sleep for few 100ms
> }
>
> But I guess there is a more elegant way. Is there ?
>
You should look at Win32::ChangeNotify and Linux::Inotify2, depending
on your platform.
Cheers,
Tal
--
Tal Kelrich
PGP fingerprint: 3EDF FCC5 60BB 4729 AB2F CAE6 FEC1 9AAC 12B9 AA69
Key Available at: http://www.hasturkun.com/pub.txt
----
The chief enemy of creativity is "good" sense
-- Picasso
----
More information about the Perl
mailing list