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

Re: Error "Can't use an undefined value as a HASH reference" while working with generated objects

by Anonymous Monk
on Oct 11, 2012 at 09:26 UTC ( #998399=note: print w/ replies, xml ) Need Help??


in reply to Error "Can't use an undefined value as a HASH reference" while working with generated objects

What I'm looking for is a tip on how I could find out right after I retrieved my object that some of his arrays/hashes are empty..

use defined, and exists, or use Data::Diver 'Dive';

if( my $want = Dive( $foo, qw/ bar anything you want / ) ){ ... }


Comment on Re: Error "Can't use an undefined value as a HASH reference" while working with generated objects
Download Code
Replies are listed 'Best First'.
Re^2: Error "Can't use an undefined value as a HASH reference" while working with generated objects
by HJO (Acolyte) on Oct 11, 2012 at 09:47 UTC

    Well thank you Anonymous Monk, I tried to use http://perldoc.perl.org/functions/defined.html, but I didn't manage to get what I wanted, srely because I don't know very well how to use it...

    I applied the answer that McA gave me and it worked just fine, so thanks for the answer, I'll look for this Dive function...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2015-07-30 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls