Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: I/O problems...what am I missing?

by clintp (Curate)
on Sep 16, 2002 at 13:37 UTC ( [id://198239]=note: print w/replies, xml ) Need Help??


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

Replies are listed 'Best First'.
Re: Re: Re: I/O problems...what am I missing?
by dws (Chancellor) on Sep 16, 2002 at 18:11 UTC
    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.

    Nonesense. I copied the code into an editor, looked at it for a moment, added use strict;, and it took less than a minute and a half to work through the "unrelated and spurious" errors before identifying the culprit. If he'd started off strict, he (probably) never would have had this problem.

    Turn on warnings instead. A -w in the #! line or a use warnings would make the problem a lot more obvious.

    That's good advice, after problems identified by use strict; have been cleaned up. To jump right into -w is kind of like debugging stuff at run-time that still has compile-time problems.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://198239]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-18 04:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found