Solved (very odd!?) was: Losing a file handle in perl
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Tue Dec 14 14:40:10 UTC 2004
On Tue, Dec 14, 2004 at 09:33:21AM -0500, Madison Kelly wrote:
> Ah, I think I am using mod_perl (almost certaily am) so that might
> explain it. The odd thing is though that in this case '$tspace' has
> never been given a value (or at least not in months). Would this still
> explain why an open file handle fails and the source of what is
> displayed is for something else? Thanks for the insight!
Quite possible yes. After all mod_perl doesn't even try to initialize
memory, so if you don't initialize ALL variables yourself at the start
of the script, or at least write a value to them before you try to read
from them, you are asking for trouble. Who knows what was in that
memory before you got it. Often you might get memory that is zeroed,
but not always. So sometimes you get lucky, sometimes you don't.
The mod_perl docs do give some hints on the kind of things that won't
work right under mod_perl. Sloppy coding where you assume default
values are a certain way and use a variable before writing a value to it
is bound to fail and is in general just a bad idea. Heck even gcc warns
you when it thinks you might use a value that isn't yet initialized to a
value. perl doesn't do that as far as I know (unless that is one of the
things -w tells you about). Good coding practices should always be
followed even when the language usually allows you to get away with it.
Lennart Sorensen
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list