in reply to question on hash behavior

The syntax in the if statement is that of a hash of hashes, four deep. Below is what I think you are really trying to do.

use strict; use warnings; use Data::Dumper; my %hash_data = (); #my $key1 = "a"; #my $key2 = "1"; #my $key3 = "B"; #my $key4 = "_"; my @keys = ("a", "1", "B", "_"); $hash_data{a} = "aValue"; for my $key (@keys) { if (exists $hash_data{$key}) { print "exists\n"; } else { print "DOES NOT EXIST\n" } } print "-----\n"; print Dumper (\%hash_data);

Replies are listed 'Best First'.
Re^2: question on hash behavior
by shamat (Acolyte) on May 04, 2016 at 06:07 UTC
    Thank you all! Autovivification is what I was missing. Today I learned something.