in reply to Re: beginner syntax question
in thread beginner syntax question
Watch the precedence of your ors! Compare the following lines of code:
my $foo = $bar || die "Bela Lugosi is dead: $!"; my $FOO = $BAR or die "I'm dead, I'm dead, I'm dead";
s0ttle's code looks pretty good (but I haven't run it), and dragonchild's point about moving variable declarations to get the smallest scope possible is good too. But their use of open() || die makes me nervous.
Remember that || has a very high precedence and or has a low precedence. In the code at the top of my post, line 1 dies if $bar evaluates to false; line 2 dies if the assignment to $FOO fails.
I've been burned by using the || die syntax before. I kept doing it after some kindly monk (I forget who) warned me not to, and doomed myself to spend much time debugging as a result.
Like Cassandra, TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: or before , for comes before or
by buckaduck (Chaplain) on Sep 19, 2001 at 20:40 UTC |