in reply to Active Munging via a pipe (code)
Here's yet another way, demonstrated from the shell:
Make the pipe, and...
... start a simple server in the background. select makes it sleep till PIPE is readable. redo in a bare block loops forever. Kick the tires:$ mkfifo logpipe $ perl -e 'open PIPE, "< logpipe"; { select 1<<fileno(PIPE),undef,unde +f,undef; print <PIPE>;redo}' &
The asynchronous operation of the server is shown in the staggered output. Clean up with$ echo foo >logpipe foo $ echo far >logpipe $ far echo fie >logpipe fie $
I think this is the Right Way® to handle your log file problem. Sleeping till there is something to read will save a lot of load on the host.$ fg perl -e 'open PIPE, "< logpipe"; {select 1<<fileno PIPE,undef,undef,un +def;print <PIPE>;redo}' # do a Ctrl-C here $
Update: Changed to use mkfifo instead of mknod, and repaired a pasto in the timeout arg of select.
After Compline,
Zaxo
|
---|
In Section
Seekers of Perl Wisdom