Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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 taking refuge in the Monastery: (5)
As of 2016-06-29 06:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (369 votes). Check out past polls.