programming-examples/perl/Hash/To tell if a given key name exists in a hash, you can use the exists operator.pl

12 lines
173 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#if ( exists($hash{$key} ) ) {
# # ..
#}
$hash{"Name"} = "A";
$hash{"Address"} = "B";
$hash{"City"} = "C";
if ( exists($hash{"City"} ) ) {
print 'exists';
}