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

Problem is that if you try to read from a file which has no new data in it, then the io->getline() function will get blocked

That's not true. It will return end-of-file. Or are you reading from something other than a plain file?

See File::Tail

  • 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 16:55 UTC

    The file that I am readnig from is constantly being written to by some other source, so its not a static file. At times getline will block when there is no new data, and at times it won't when there is new data.

      At times getline will block when there is no new data

      I'll repeat: No, it won't.

      $ perl -le'$|=1; for (;;) { print "poke"; sleep 1; }' > file & perl -M +IO::Handle -e'sleep 3; print while $_ = STDIN->getline; print "exited + instead of blocking\n"' < file ; fg [1] 29483 poke poke poke poke exited instead of blocking perl -le'$|=1; for (;;) { print "poke"; sleep 1; }' > file ^C $ cat file ; rm file poke poke poke poke poke poke