in reply to Re^2: What protects me from doing this stupid thing..?
in thread What protects me from doing this stupid thing..?

Still, I thought there was (arguably) a valid point made.

Given that perl -we '10' produces the "Useless use of a constant in void context" warning, couldn't it be argued (by someone that wanted to be extremely picky) that perl -we '0 || 10' should produce the same (or similar) warning ?

Cheers,
Rob

Replies are listed 'Best First'.
Re^4: What protects me from doing this stupid thing..?
by dogz007 (Scribe) on Aug 12, 2007 at 18:12 UTC
    They might be picky, but it's morely likely they misunderstand the meaning of "Useless" in this context. Execution of perl -we "10" returns an error because it does absolutely nothing. In contrast, perl -we "0 || 10" makes a choice. It matters not that the choice is ultimately unnecessary. The constant value is examined in order to make the choice; therefore, it is a useful value. Perl cannot be expected to determine whether or not a programmer makes poor choices. It's like the Oracle: it cannot see past a choice it does not understand.