U
usenet
It seems there are many opportunities to write bad code such as this:
open $file || die $!;
where the || binds too tightly... Perl thinks I mean "open ($file ||
die)" instead of "open($file) || die".
Of course, I can avoid such misunderstandings by always putting my
argument in parens, or by using lower priority "or".
So I got to thinking... maybe I should always use "or die" and NEVER
use "|| die". Yet, I often see the "|| die" syntax - this seems to be
the "usual" programming practice in Perl, so I wonder if I'm missing
some beneficial behavior of "|| die" and if my idea to always use "or
die" is ill-advised.
Thanks.
open $file || die $!;
where the || binds too tightly... Perl thinks I mean "open ($file ||
die)" instead of "open($file) || die".
Of course, I can avoid such misunderstandings by always putting my
argument in parens, or by using lower priority "or".
So I got to thinking... maybe I should always use "or die" and NEVER
use "|| die". Yet, I often see the "|| die" syntax - this seems to be
the "usual" programming practice in Perl, so I wonder if I'm missing
some beneficial behavior of "|| die" and if my idea to always use "or
die" is ill-advised.
Thanks.