in reply to selecting from a number of different input sources.

This is not what you are asking but, can't you use sockets instead of files? Also, if you are on Linux you can check out http://search.cpan.org/dist/Linux-Inotify2/.
  • Comment on Re: selecting from a number of different input sources.

Replies are listed 'Best First'.
Re^2: selecting from a number of different input sources.
by jasoncollins (Novice) on Jul 21, 2010 at 17:01 UTC

    This is how I am opening up the file to read, not sure what do I need to do to read the text files as a socket instead, and how that would help.

    my $io = new IO::Handle; open (my $fh, '<', $FILE) or die $!; if ($io->fdopen(fileno($fh), "r")) { ...

      It's not immediately clear from the docs, but just saying use IO::Handle entitles you to call IO::Handle methods on normal file handles like your already opened $fh.  In other words, your snippet could be simplified as follows:

      use IO::Handle; open (my $fh, '<', $FILE) or die $!; # then simply call method from IO::Handle $fh->getline();

      This doesn't answer the question how to make a socket out of a regular file, but I thought it's worth mentioning nevertheless...