in reply to One out of three ain't bad
Avoid the obfuscating punctuation:
if( 1 == grep $_, $x, $y, $z )
Or, using a more versatile trick:
if( 1 == !!$x + !!$y + !!$z )
But note that some will kvetch that the fact of !0 == 1 is "not defined" in Perl. But that ship has already sailed; practicality actually prevents Perl from changing the value of "true" to something other than 1, even if this property was intentionally left undefined.
- tye
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: One out of three ain't bad (order)
by ph713 (Pilgrim) on Oct 22, 2005 at 08:42 UTC | |
by Tanktalus (Canon) on Oct 22, 2005 at 14:46 UTC | |
by eric256 (Parson) on Oct 23, 2005 at 04:02 UTC | |
by Tanktalus (Canon) on Oct 23, 2005 at 15:39 UTC | |
by sauoq (Abbot) on Oct 26, 2005 at 04:39 UTC | |
by eric256 (Parson) on Oct 24, 2005 at 02:08 UTC | |
Re^2: One out of three ain't bad (order)
by Dr. Mu (Hermit) on Oct 23, 2005 at 04:21 UTC | |
by mrborisguy (Hermit) on Oct 24, 2005 at 04:51 UTC | |
by Dr. Mu (Hermit) on Oct 24, 2005 at 17:23 UTC | |
by tye (Sage) on Oct 25, 2005 at 03:37 UTC | |
by Dr. Mu (Hermit) on Oct 26, 2005 at 01:59 UTC | |
|
In Section
Seekers of Perl Wisdom