[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] not defined $bucket || $bucket eq '???'



On Wed, Dec 3, 2008 at 6:50 PM, Jay Hannah <jay@jays.net> wrote:
> I'm betting this happens due to operator precedence. Reading "perldoc
> perlop" doesn't help me much at a glance since I'm not sure where 'defined'
> falls in the documented precedence order stack. But let's assume for a
> second that the precedence of 'defined' is higher than that of 'or' but
> lower than that of '||'. If that's true, then:

Back when I was first learning Perl, it was stressed heavily to me by
a friend that 'or' is basically the lowest precedence operator
available (technically xor is the same, but it's much more rarely
used).  The advantage of this is that you never have to wonder about
precedence when doing something like:

  do stuff or die "stuff didn't work";

As the 'or' will always fall through after the rest.  I'm going to
guess that you hit it on the head regarding || and defined, as I know
|| falls well ahead of 'or' in precedence (along with everything
else).

> j

-- 
Christopher