The delete()
method in Perl is used to delete the specified keys along with their associated value from a hash.
The syntax of the delete()
method is given below:
delete(hash(key))
hash
: This is the hash instance we want to delete some entries from.
key
: This is the key that gets deleted along with its corresponding value.
The value returned is the value of the key that was deleted.
# create a Hash value%hash1 = ("Google" => "G","Netflix" => "N","Amazon" => "A","Apple" => "A","Meta" => "M");# delete some entries$deletedValue1 = delete($hash1{"Google"});$deletedValue2 = delete($hash1{"Meta"});# print deleted elementsprint "$deletedValue1\n";print "$deletedValue2";
delete
method.