How can I asynchronously monitor a file in Perl?
        Posted  
        
            by Hussain
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Hussain
        
        
        
        Published on 2010-04-15T22:39:05Z
        Indexed on 
            2010/04/16
            4:03 UTC
        
        
        Read the original article
        Hit count: 304
        
I am wondering if it is possible, and if so how, one could create a perl script that constantly monitors a file/db, and then call a subroutine to perform text processing if the file is changed. I'm pretty sure this would be possible using sockets, but this needs to be used for a webchat application on a site running on a shared host, and I'm not so sure sockets would be allowed on it.
The basic idea is:
- create a listener for a chat file/database
- when the file is updated with a new message, call a subroutine
- the called subroutine will send the new message back to the browser to be displayed
Thanks in advance.
© Stack Overflow or respective owner