http://www.perlmonks.org?node_id=201405


in reply to (Golf) Warningless Comparison

A shorter method, which may or may not work, depending on context, is (($x || 0) eq ($y || 0)) However, if 0 is a legitimate value for your code (as it probably is if undef is), you can try to find something that isn't. I'd try something like the default seperator variable ($;), which prints as a weird symbol on my machine.(($x || $;) eq ($y || $;)) If you take the extra spaces out, that's 18 chars.

elusion : http://matt.diephouse.com

Update: This wasn't in response to the hash aspect of the meditation, sorry.

Replies are listed 'Best First'.
Re^2: (Golf) Warningless Comparison
by tadman (Prior) on Sep 28, 2002 at 05:00 UTC
    In the hash table that I constructed, I put in 0 as a plausible value. It's a good habit to make, putting deliberately false values in your test data. You never know when you're going to do something odd. Form data, in particular, is one example.

    Apart from the amusement factor, I think I've found a reasonable solution. Silly me.