![]() |
|
There's more than one way to do things | |
PerlMonks |
making sure a file is not currently being written toby why_bird (Pilgrim) |
on Jun 05, 2008 at 13:37 UTC ( #690425=perlquestion: print w/replies, xml ) | Need Help?? |
why_bird has asked for the wisdom of the Perl Monks concerning the following question: Dear Monks I have a file which is being written by a sub in one module, let's call it Write() in Write.pm. My script then later calls &Check() in Check.pm which opens that same file, runs through it and performs a series of checks on each line to make sure everything is in order. However, I think the file is still being written when I call &Check() since for a line near the end of the file I keep getting the error
The line should read '1.21633032597832 + 1.8765165060i and indeed it does when I open and check the config file. There are also hundreds of lines almost identical to this one and they don't cause a problem (there's a regex to capture imaginary numbers to divert them away from the numerical comparison mentioned in the error). This problem also goes away when I insert sleep(3) between &Write() and &Check() So..
Sorry for the rather rambling question, this is a problem that's caught me out a few times in various projects so it'd be good to figure it out Cheerswhy_bird Those are my principles. If you don't like them I have others. -- Groucho Marx .......
Back to
Seekers of Perl Wisdom
|
|