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...