------------------------------------------------ On Wed, 16 Jul 2003 21:33:56 -0400, "Jose M.Herrera" <[EMAIL PROTECTED]> wrote:
> I need to make a perl program which print "Changed!" when a file xx.txt is > changed. > please, any idea?? > > Thanks for all.. > Usually two-three options with this type of task on varying levels. 1. Is your program going to run out of a scheduler (aka cron, etc.)? Or will it be continually running? In the latter case, is it ok for it to sleep/block between intervals or must it be non-blocking? 2. What kind of change are you trying to detect? Checking the mtime against the system time will tell you whether the file was modified, but not necessarily that it's contents changed. To detect changes in contents you are probably best off using some type of hashing module, such as Digest::MD5 or Digest::SHA1, which will provide a unique 'hash' that changing the contents of the file, then rehashing you can match against. 3. In the case of the scheduler you will need some way to save the last checked state (outside of main memory, to a file, database, etc.), aka the modified time, the hash, etc. between sessions. 4. Are you checking multiple files on each pass or only a single one? Is it a large list? Are the files always the same and specifically determined, or do you have to 'find' them? Depending on how precise, etc. you need to be these may not cut it, but are the right questions to be asking first. You should start by redefining the problem into smaller more manageable chunks until the implementation becomes obvious, then we can help you with some of the details of that implementation. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]