[Israel.pm] How to detect a new file in a directory without busy wait ?

Tal Kelrich tal at musicgenome.com
Thu Mar 27 12:29:05 EET 2008


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
----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://perl.org.il/pipermail/perl/attachments/20080327/25908026/attachment.pgp 


More information about the Perl mailing list