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?
[choroba]: that's 2012
[zentara]: I just acquired a computer with the card type, and wondered if it was best to stick with the open-source code or use NVIDIA's proprietary code
[zentara]: do you feel good about a non-open-source code, being in control of your display functions?
[choroba]: If you're not going to play 3d games on it, using the open source driver should be enough

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-05-26 14:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?