Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: (Golf) Warningless Comparison

by elusion (Curate)
on Sep 28, 2002 at 02:35 UTC ( #201405=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://201405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2019-07-21 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If you were the first to set foot on the Moon, what would be your epigram?






    Results (7 votes). Check out past polls.

    Notices?