You have never mistyped a filename?
Who types filenames? I use Windows at work, and Windows has a nifty
shortcut that allows the insertion of filenames without typing them.
Thank you very much -- you've made my day. ;-)
checking the return value from open() is needed in every situation,
because it can fail in any situation.
Maybe this is the point. It's NOT needed in every situation. We all
can think, in theory anyway, and we all can determine when to take
shortcuts and when to paint by the numbers. Yesterday I revisited a
script that I had written some time ago and in which I had used a
number of infamous Perl shortcuts, and which took me several minutes
to interpret -- and which I immediately rewrote in a literate
programming idiom because I needed to reuse the logic in what will
become a standard script.
It's not that using shortcuts is wrong, and that using literate
programming practices is right -- it just depends.
I have open() with return value checking saved in an edit buffer, so
I won't be tempted to spew bad code upon the world.
Now, that's a good idea.
Code posted here is likely to be copied by posters days, weeks or
years from now.
Seeding failure is a disservice to our community.
Can't disagree with that.
If you cannot be troubled to post Good Code, then don't post code,
Perl programmers will be the better for it.
And what is 'good code?' I got slammed in another thread a few weeks
ago for not using typical shortcuts, such as using $_ in a block
instead of assigning $_ to $line and using $line in the block.
Readability and terseness are both virtues, but they mostly are
mutually exclusive. Example: I've been writing Lisp in my off time and
have learned that writing Lisp is easy because it's very abstract, but
reading Lisp is difficult because it's very abstract.
'Good code' is many times a matter of opinion, and we've got better
things to do than imposing our opinion as code police.
CC.