Web | This Site

Perl Home
PERL Functions
© 2011 TutorialsPoint.COM

| Home |  | References |  | About TP |  | Advertising

# PERL delete Function

## Syntax

delete LIST

## Definition and Usage

Deletes the specified keys and associated values from a hash, or the specified elements from an array. The operation works on individual elements or slices.

## Return Value

- undef if the key does not exist

- Value associated with the deleted hash key or array index.

## Example

The following (inefficiently) deletes all the values of %HASH and @ARRAY:

        foreach $key (keys %HASH) {
    	delete $HASH{$key};
        }

        foreach $index (0 .. $#ARRAY) {
    	delete $ARRAY[$index];
        }

And so do these:

     delete @HASH{keys %HASH};

     delete @ARRAY[0 .. $#ARRAY];

Advertisement

Online Image Processing

Indian Baby Names