in reply to Why is this code not printing hash key?

You are exiting the 'for' loop at the first key that mismatches.

i.e. you are not checking ALL keys.

You are also not using the hash at what it is best at - direct lookups of the key.

Anyway - your code would work better if coded as:

my $selection = <>; chomp $selection; my $found=0; foreach my $key (keys %hash) { if ($key eq $selection) { print "\n"; $found=1; last; } } $found or print "\nThe domain you entered is not on the list above. + Now exiting script.\n";

        What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?
              -Larry Wall, 1992