in reply to checking if hashref value exists based on a dynamic array

One important thing to keep in mind while working with large complex data structure and checking for existence is that some hash entries will be created just by using them. For example,
my %hash = ( a => { ab => { ac => 'yup', }, }, ); # Check for existence if (exists $hash{aa}->{ab}->{ac}) { ## Notice that 'aa' is a typo an doesn't exist ## but will be auto-created and now contain a ## hash ref with one entry 'ab'. print "ac exists.\n"; ## won't get printed } if (exists $hash{aa}) { ## This will succeed because $hash{aa} was auto ## created above. print "aa exists.\n"; ## will get printed }
The exists check works on the last part of the data structure and not each step through the data structure. Meaning:
if exists $hash{aa} ## exists doesn't check this ->{ab} ## Nor this ->{ac} ## Ah ha! exists does check here ;
Everything before that last part of the data structure gets auto created if it doesn't exist. Only the last part will not. Just keep that in mind. -spencer