The delete function removes a value from an element of an array but not the element itself. : delete « Array « Perl






The delete function removes a value from an element of an array but not the element itself.

   

The value deleted is simply undefined.

# Removing an array element
@colors=("red","green","blue","yellow");
print "@colors\n";
delete $colors[1];  # green is removed
print "@colors\n";
print $colors[1],"\n";
$size=@colors;      # value is now undefined
print "The size of the array is $size.\n";

   
    
    
  








Related examples in the same category