如何在Perl中从散列中删除键?

如何在Perl中从散列中删除键?,perl,hash,perl-data-structures,Perl,Hash,Perl Data Structures,如何从现有地图中删除密钥 if (exists $sampleMap{1}) { #Here I want to remove the "1" key from sampleMap } 使用delete删除哈希键: if (exists $sampleMap{1}) { delete $sampleMap{1}; #Here I want remove the "1" key from sampleMap. } 有关更多详细信息,请查看。不需要检查密钥是否存在,如果不

如何从现有地图中删除密钥

if (exists $sampleMap{1})
{
      #Here I want to remove the "1" key from sampleMap
}

使用
delete
删除哈希键:

if (exists $sampleMap{1})
{
      delete $sampleMap{1}; #Here I want remove the "1" key from sampleMap.
}

有关更多详细信息,请查看。

不需要检查密钥是否存在,如果不存在,delete()不会抱怨。