Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: How can I re-program the exists function? (false)

by tye (Cardinal)
on Aug 27, 2012 at 16:47 UTC ( #990020=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How can I re-program the exists function?
in thread How can I re-program the exists function?

my goal is to test an entry from a hashref, these entries contains objects

A reference to an object can't be undef() or even false (unless you do some strange overloading) so what you want is trivial:

mytest( $hash{object} || '' ); sub mytest { my( $obj ) = @_; return if ! $obj; }

The "|| ''" is there just to ensure that autovivification doesn't happen. I believe current versions of Perl actually avoid autovivification for this case if you don't assign to $_[0] in the mytest sub, but that's the kind of detail that is subject to change so I tend to "play it safe" on such issues.

- tye        


Comment on Re^3: How can I re-program the exists function? (false)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (16)
As of 2014-09-30 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (378 votes), past polls