Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: exists on hash autovivifies right?

by menolly (Hermit)
on Jun 30, 2008 at 21:18 UTC ( [id://694834] : note . print w/replies, xml ) Need Help??


in reply to exists on hash autovivifies right?

I've taken advantage of short-circuiting operators to deal with this in the past, like so:
if (exists($x->{a}) && exists($x->{a}->{c}) { #do stuff }

Might get annoying if your hash is particularly deep, though.