programming-examples/perl/Hash/To tell if a given key name exists in a hash, you can use the exists operator.pl
2019-11-15 12:59:38 +01:00

12 lines
173 B
Perl

#if ( exists($hash{$key} ) ) {
# # ..
#}
$hash{"Name"} = "A";
$hash{"Address"} = "B";
$hash{"City"} = "C";
if ( exists($hash{"City"} ) ) {
print 'exists';
}