in reply to Recursive file opening: reading an undef at the end of file

Let me walk through one peculiar segment of the code...

while ( <$fh> ) { chomp; # Remove trailing newlines (a subset of \s) s/\s//g; # Remove ALL whitespace. next if /^#/; # Skip comments. next if /^\s*$/; # Skip lines with space, or lines with nothing. # This doesn't make sense because you # already removed all space. But it # works because you allow it to match # 'nothing' too. next if $_ eq "";# This line is never true, because # you already skipped lines with nothing # in the previous statement. #......

In other words, much of what you're doing there is either redundant or otherwise peculiar.

Next, your "read_cal" function is being called with two arguments, but within the function, you're only using the first argument.

I didn't even look at what you're doing in the if (!$mode... code, because I don't see $mode being set.

Also, you're only printing out hash elements with a value equal to one, though it might be simpler to just check for the existance of a hash element.

Update: None of these are the central problem. Congrats Roger for finding the straw that breaks this camel's back. I found a lot of other issues, but you found the big one. I'd recommend considering reworking the code a bit based on the suggestions people have given in this thread though, as the result will be cleaner.


Dave

Replies are listed 'Best First'.
Re: Re: Recursive file opening: reading an undef at the end of file
by thor (Priest) on Dec 24, 2003 at 03:47 UTC
    Yup...I had a lot of extraneous stuff in there because I was trying to get rid of the error. Originally, I had:
    while(<$fh>) { chomp; next if /^#/; next if /^\s*$/; ...
    I'd like to think that I'm not a complete dolt...:-)

    thor