in reply to Hopefully a simple mistake

The debugger might be helpful here. Just do a
perl -d chuckular_prog.pl # Or whatever the filename is
and then stop it in the problem area to see what's going on. perlman:perldebug

Other than that, I'd recommend localizing your variables with "my" and putting "use strict" into the beginning, plus running with -w (which you're of course already doing, right?)

Also, remove your data file and re-run the program. Although the data has changed, it's best to double-check. Definitely add the "or die".

stephen