NAME

POE::Component::DirWatch - POE directory watcher

SYNOPSIS

use POE::Component::DirWatch;

POE::Component::DirWatch->spawn(
  Alias        => 'dirwatch',
  Directory    => '/some_dir',
  Filter       => sub { $_[0] =~ /\.gz$/ && -f $_[1] },
  Callback     => \&some_sub,
  PollInterval => 1,
);

DESCRIPTION

POE::Component::DirWatch watches a directory for files. It creates a separate session which invokes a user-supplied callback as soon as it finds a file in the directory.

Its primary intended use is processing a "drop-box" style directory, such as an FTP upload directory.

ARGUMENTS

Alias

The alias for the DirWatch session. Defaults to dirwatch if not specified.

Directory

The name of the directory to watch. This is a required argument.

PollInterval

The intervals between polls of the directory, in seconds. Default to 1 if not specified.

Callback

A reference to a subroutine that will be called when a matching file is found in the directory.

This subroutine is called with two arguments: the name of the file, and its full pathname. It usually makes most sense to process the file and remove it from the directory.

This is a required argument.

Filter

A reference to a subroutine that will be called for each file in the watched directory. It should return a TRUE value if the file qualifies as found, FALSE if the file is to be ignored.

This subroutine is called with two arguments: the name of the file, and its full pathname.

If not specified, defaults to sub { -f $_[1] }.

SEE ALSO

POE(3), POE::Component(3)

AUTHOR

Eric Cholet, <cholet@logilune.com>

Thanks to Matt Sergeant for POE insights and bug reports, and David Rigaudière for Win32 testing.

COPYRIGHT

Copyright 2002 Eric Cholet. All Rights Reserved. This is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 214:

Non-ASCII character seen before =encoding in 'Rigaudière'. Assuming CP1252