Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Reopen file when contents changed?

by merlyn (Sage)
on Jun 07, 2005 at 14:26 UTC ( #464316=note: print w/replies, xml ) Need Help??


in reply to Reopen file when contents changed?

I'm not sure about things in /proc Normally, if you stat the file and record dev/ino/ctime, and then read the data, you can simply go into a sleep-1 loop until the stat of dev/ino/ctime changes.

For example:

my @base = stat($FILE); my $base = "@base[0,1,10]"; # dev/ino/ctime while (1) { ... read $FILE here, and process it ... while (1) { my @new = stat($FILE); my $new = "@new[0,1,10]"; # current dev/ino/ctime if ($base ne $new) { # changed $base = $new; # reset last; # restart outer loop } sleep 1; # delay because no change } }

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://464316]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2022-08-08 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?