Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: (Golf) Warningless Comparison

by elusion (Curate)
on Sep 28, 2002 at 02:35 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://201405]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found