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
Argument "1.21633032597832 + 1.8765165060" isn't numeric in numeric lt + (<) at Check.pm line x, <CONFIG> line y.
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..
- Is there a way to tell whether the file is still being written?
- Does it sound like this is the problem or could there be something I'm overlooking?
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
.......
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: making sure a file is not currently being written to
by moritz (Cardinal) on Jun 05, 2008 at 13:43 UTC | |
by Corion (Patriarch) on Jun 05, 2008 at 13:47 UTC | |
by moritz (Cardinal) on Jun 05, 2008 at 13:57 UTC | |
by why_bird (Pilgrim) on Jun 05, 2008 at 14:21 UTC | |
Re: making sure a file is not currently being written to
by Gangabass (Vicar) on Jun 05, 2008 at 14:52 UTC | |
Re: making sure a file is not currently being written to
by Anonymous Monk on Jun 06, 2008 at 08:21 UTC |