The delete Function : delete « Hash « Perl






The delete Function

    

Format: delete $ASSOC_ARRAY{KEY}

#!/usr/bin/perl
%employees=(
            "Tester" => "Joe",
            "Coder" => "Teddy",
            "Clerk" => "Tom",
           );
$layoff=delete $employees{"Colder"};
print "We had to let $layoff go.\n";

while(($key, $value)=each(%employees)){
    print "$key: $value\n";
}

   
    
    
    
  








Related examples in the same category

1.Delete the element with key 'Joe' from %hash
2.Delete from hash
3.Delete an entry in hash
4.The delete operator removes a key/value pair from an associative array.
5.Check key existance after using 'delete' operator