The exists function returns true if a hash key (or array index) has been defined, and false if not.
#Format: exists $ASSOC_ARRAY{KEY}
#!/usr/bin/perl
%employees=("Tester" => "Joe",
"Coder" => "Teddy",
"Clerk" => "Tom",
);
print "exists.\n" if exists $employees{"Tester"};
print "The Clerk exists.\n" if exists $employees{"Clerk"};
print "The Boss does not exist.\n" if not exists $employees{"Boss"};
Related examples in the same category