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);