cartercc said:
This isn't a big deal. I often don't check the return value of open
and I'm quite willing to accept the consequences. However, this only
applies to scripts written for ME on MY system, and I know that system
intimately. When I'm busy, I do this literally hundreds of times a
week, perhaps (on a very long day) a hundred times a day. I know what
I'm doing.
I don't think anyone's upset if you do this yourself on your own systems
for your own scripts, and it doesn't affect anyone else. Still, it
doesn't seem like a good idea out of laziness or being busy. Checking
the return of open should actually save you time in every case, so it
just seems strange you'd not _want_ to do it. Of course, if you choose
not to, that's cool, since you don't seem to do it that way for other
people.
Still, you replied to the thread saying what appeared to suggest that
not everyone should check the return value in every case. I don't
imagine any circumstance or reason in a single case not to, and it
should even save time and hassles. If you just meant to not use
something nasty like die(), then that's completely valid, though one
really should never have a reason not to check the return value.
Saying you know you should, but don't always do it or want to, is
another thing, but it just seemed that you were suggesting it and it
struck me as odd for that reason.
For another example, consider warnings. One of my tasks is to process
a file which may consists of several hundred thousand rows, totaling
different kinds of values. When I run the script with warnings, I get
an uninitialized value warning for every row printed to the screen,
and the script takes a significant amount of time to run. When I run
the script without warnings, the script runs quickly. To silence the
warnings I can either (1) initialize a hash value for each row, or (2)
run without warnings. I choose (2).
There is probably a better way to do it, where you're not having to
initialize each row (but that's just a guess without seeing the
script). Sometimes things here or there can be annoying and you can
save time, but when you do that, I don't know that you could ever trust
the output of the script when it all comes down to it, and in which
case why take the time to create the script or run it, unless you're
just doing something for a general idea or rough estimate of the
output?
Again, this isn't a big deal, and I TOTALLY AGREE that the return
value for open() should generally be checked, and that warnings should
generally be enables. However, for the reasons I stated, I often don't
do this, and I am perfectly willing to accept the consequences.
I think people would disagree about it not being a big deal, but I also
don't think anyone minds how you run your own personal scripts. I've
never seen anyone that didn't make a goof in their code at some point,
and I'd prefer to have something catch it right away. I really can't
say I agree there are reasons, but to each their own.