http://www.perlmonks.org?node_id=198239


in reply to Re: I/O problems...what am I missing?
in thread I/O problems...what am I missing?

use strict;
And the problem will jump right off the page.
I'm sorry, that's just wrong. A use strict would cause 60 completely unrelated and spurious errors to "jump right off the page" at our poor unsuspecting programmer. It wouldn't be helpful at all and probably counter-productive.

He'd probably do what every new programmer does when they see this: declare everything with my until the errors go away. Which means he'd probably declare the wrong variable names with my too in the massive effort to track down and declare all of his variables. So in effect he'd be using strict for no good reason, waste his time, cluttered his code, and still not found his error. Looking at this script he probably doesn't need the benefits of lexicals anyway.

Turn on warnings instead. A -w in the #! line or a use warnings would make the problem a lot more obvious. In fact, perl tells you *exactly* what the problem is. And finds another one for you as well.


PS to the original poster: the codeopen INPUT, "a:scores.txt" || die "Cannot locate input file: $!"; has the wrong precedence and doesn't do what you think it does. Try an "or" instead of "||".