in reply to Using null filehandle

The one thing I notice about your code is that you have three loops that read from <>. It is possible that some difference in the input results in the inner functions reading extra data. t is also possible that you missed a spot when changing the code so it was reading from a different file handle. You might want to add debugging code to print the line number and file for each line to see that the right file and lines are being read.
print STDERR "$ARGV:$.:$line";

I would suggest rewriting the code so that there is only one loop that reads lines. Use flags or a state variable to control the processing. This makes it easier to analyze where the file is being read and what the state the processing is in at each stage.

Replies are listed 'Best First'.
Re^2: Using null filehandle
by digger (Friar) on Jun 09, 2004 at 10:34 UTC
    I agree that having reads in multiple loops does make solving this problem a little more complex. Since it is such a short script, I may try rewriting it using a single loop, although that could get ugly as well.

    I am still stumped as to why the behavior changes when I use an explicit filehandle versus taking advantage of the implicit filehandle syntax.

    Thanks for your input,
    digger