in reply to comparing two values under 'perl -w'

Shouldnt use $a and $b as they can have bizzare side. And i have no idea if this is more or less elegant than yours... (IMO its easier to understand, but then again I like ternary ops.)
my $equal=defined($x) && defined($y) ? $x==$y : !defined($x) && !defin +ed($y) ? 1 : 0;

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.

Replies are listed 'Best First'.
Re: Re: comparing two values under 'perl -w'
by danger (Priest) on Apr 02, 2002 at 21:19 UTC

    Can we not just skip the secondary ternary here?

    if(defined($x) && defined($y) ? $x==$y : !defined($x) && !defined($y)) + {
      Doh.

      Good point. I certainly could have.

      :-)

      Yves / DeMerphq
      ---
      Writing a good benchmark isnt as easy as it might look.