Perl | delete() Function Last Updated : 25 Jun, 2019 Comments Improve Suggest changes Like Article Like Report Delete() in Perl is used to delete the specified keys and their associated values from a hash, or the specified elements in the case of an array. This operation works only on individual elements or slices. Syntax: delete(LIST) Parameters: LIST which is to be deleted Returns: undef if the key does not exist otherwise it returns the value associated with the deleted key Example 1: Implementing delete() on a Hash Perl #!/usr/bin/perl # Initializing hash %hash1 = ('Geeks' => 45, 'for' => 30, 'Now' => 40); # To delete the List passed as parameter $deleted_element = delete($hash1{'for'}); # Printing elements of Hash print "$hash1{'Geeks'}\n"; print "$hash1{'for'}\n"; print "$hash1{'Now'}\n"; # Printing the deleted element print "Deleted element: $deleted_element"; Output: 45 40 Deleted element: 30 Example 2: Implementing delete() on an Array Perl #!/usr/bin/perl # Initializing array @array1 = (10, 20, 30, 40, 50, 60); # To delete the array element at index 2 $deleted_element = delete(@array1[2]); # Printing elements of Array print "Updated Array: @array1"; # Printing the deleted element print "\nDeleted element: $deleted_element"; Output: Updated Array: 10 20 40 50 60 Deleted element: 30 Comment More infoAdvertise with us Next Article Perl | delete() Function C Code_Mech Follow Improve Article Tags : Perl Perl-function Perl-Hash-Functions Similar Reads Perl | Useful Hash functions A hash is a set of key-value pairs. Perl stores elements of a hash such that it searches for the values based on its keys. Perl provides various functions to perform operations on Hashes, such as to return values of the hash, to delete elements from a hash, etc. Example: Perl #!/usr/bin/perl # Initi 2 min read Ruby | Hash delete() function delete() is an Hash class method which deletes the key-value pair and returns the value from hash whose key is equal to key. Syntax: Hash.delete() Parameter: Hash array Return: value from hash whose key is equal to deleted key. Example #1: Ruby # Ruby code for delete() method # declaring Hash value 1 min read Ruby | Set delete? function The delete?() is an inbuilt method in Ruby which deletes the given object from the set and returns the self object. In case the object is not present, it returns nil. Syntax: s1.name.delete(object) Parameters: The function takes a mandatory parameter object which is to be deleted. Return Value: It r 1 min read PostgreSQL - DELETE The DELETE statement is a key command in PostgreSQL used to remove existing records from a table. By using DELETE, you can eliminate unwanted or outdated records, helping keep your database organized and up to date.In this article, we will explore the DELETE statement, its syntax, and some practical 4 min read delete keyword in C++ delete is an operator that is used to destroy array and non-array(pointer) objects which are dynamically created by the new operator.delete can be used by either using the delete operator or delete [ ] operator.The new operator is used for dynamic memory allocation which stores variables on heap mem 4 min read Ruby | Set delete() function The delete() is an inbuilt method in Ruby which deletes the given object from the set and returns the self object. In case the object is not present, it returns self only. Syntax: s1.name.delete(object) Parameters: The function takes a mandatory parameter object which is to be deleted. Return Value: 1 min read Mongoose deleteMany() Function The deleteMany() function is employed to remove all documents meeting specified conditions from a collection. Unlike the remove() function, deleteMany() deletes all matching documents without considering the single option. This method is essential for Node.js developers working with Mongoose, as it 4 min read Express app.delete() Function The `app.delete()` function is utilized to handle HTTP DELETE requests for a specified path. It takes the path as a parameter and also accepts callback functions as parameters to handle the request.Syntax: app.delete(path, callback)Parameters: path: It is the path for which the middleware function i 2 min read SQL DELETE Statement The SQL DELETE statement is one of the most commonly used commands in SQL (Structured Query Language). It allows you to remove one or more rows from the table depending on the situation. Unlike the DROP statement, which removes the entire table, the DELETE statement removes data (rows) from the tabl 4 min read remove() in C In C, remove() is a standard library function is used to delete a file from the file system. It provides a simple way to manage files in the storage from a C program.Example:C#include <stdio.h> int main() { // Remove the file remove("gfg.txt") return 0; }OutputFile deleted successfully.Explana 3 min read Like