Solved (very odd!?) was: Losing a file handle in perl

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Tue Dec 14 02:08:00 UTC 2004


This has to be the oddest bug I ever came across... it's fixed, and I'll 
write what happened in case it helps someone later:

After sending this message I tried to look at the source of the page 
being displayed (web-interface). The very, very odd thing was that the 
source was for an entirely different page from what was being displayed. 
The source was the source you would see when you first start the program 
  before you have logged in even though what was being displayed was a 
page from within the program (where it displays partition information). 
The actual, current partition information was being rendered and 
displayed by the browser but the source was different anyway. This was 
try after clearing the cache and even in a separate browser that I had 
never run the program in.

I also tried closing and re-opening the file handle after returning to 
the main script but that didn't help as well. So, not knowing what else 
to try, I started temporarily deleting chunks of code until the problem 
went away. Doing this I narrowed the problem down to, of all things, a 
simple variable that I wasn't using any more. The oddest part is that 
the string variable ($tspace) is not used or called anywhere anymore. It 
-should- have simply been empty or null.

Once I changed it to use the proper string variable name 
($image_name{'tspace'}) the problem went away, the right source was 
shown in the browser and the logs started working again.

Can anyone explain how this could happen?

Thanks!

Madison

Madison Kelly wrote:
> Hi all,
> 
>   I hope all my questions aren't a pain!
> 
>   I have been re-writting my program heavily (my first go was to "get it 
> working", now I'm making it work well). Part of this process was to 
> create a library file for sub routines. I have a section where the main 
> program calls a subroutine which in the process of running launches 
> other sub routines and sometimes itself a second time.
> 
>   The script seems to be working fine because the program is working 
> through and past this call but what I do lose is an open filehandle I 
> use to write my logs out to. The first sub routine called by the program 
> will write out to the file right up to the last line but once it returns 
> the main program will no longer write out to the open file. I know the 
> problem isn't in the main file because if I remark the sub routine call 
> the log file stays open (??) or at least continues to get data.
> 
>   The open log file works (I can write data to it) through all of the 
> sub-routine jumps and returns... It's just the last return that seems to 
> cause problems.
> 
>   Has anyone run into this before? Have any suggestions or pointers?
> 
>   As always, thank you all very much!
> 
> Madison

--
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