in reply to Re^2: list lines not found in config (while+if)
in thread list lines not found in config (while+if)
I think there can be some legitimate differences of opinions on these things.
First on the subject of:
open ... $filename || die makes for an unhappy life.
Out of force of habit, I use more parens so that this sort of thing is not a problem. open (...) or die "..." is the same as open (...) || die "...". Which is NOT the same as open ... || die "...". So you are correct that there is a potential problem here! I recommend to always use parens to make things clear. Especially on calls to the O/S!
Use of ?! is a grey area here.
Probably more important is one thing that
we didn't talk about: the significance of \n in a "die". If there is no
\n in the "die text" Perl will report the text message and the program line
number. If I get called on the phone by a user with a fatal error, that is
very useful information to me! If there is a \n in the die, I won't get the line number! Whether or not there is a ?! error is of much
less importance.
So if user types: C:\PROJECTS\PerlMonks>test.pl f3 f2.txt
ERRORMSG: unable to open f3 at C:\PROJECTS\PerlMonks\test.pl line 6.
I know what happened. If we have the ?! also, then we get:
ERRORMSG: unable to open f3 No such file or directory at C:\PROJECTS\PerlMonks\test.pl line 6.
That in this case is pretty much the same thing.
Most important is a good error message and leaving off the \n in the die statement. BUT, I would agree to stick that $! thing in there! I usually do it, but in this case sometimes we overburden new folks with the 2nd level of detail that isn't so important at the time.
I would like to be educated re: security holes. For these very short 10 line things, I don't see a problem with the way that I opened the 2 read-only files. Stuff that comes from cgi scripts etc is way different. There isn't a problem here, but I suspect that the answer will be "hey, there could be a problem in a another situation...".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: list lines not found in config (while+if)
by GrandFather (Saint) on Apr 08, 2009 at 03:28 UTC | |
by Marshall (Canon) on Apr 08, 2009 at 04:43 UTC |