Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove keys from hash in Perl?

How do I remove the key from an existing map?

if (exists $sampleMap{1})
{
      #Here I want to remove the "1" key from sampleMap
}
like image 365
Balaji Avatar asked Jan 13 '23 12:01

Balaji


1 Answers

Use delete for deleting the hash keys:

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

For more details, take a look at delete.

like image 101
Nikhil Jain Avatar answered Jan 25 '23 15:01

Nikhil Jain