Remove all of the values from an array in Perl (undef)

Home > Search

In this example, the @fruit array contains fruits.

my @fruit = qw(orange apple peach pear);


prrint @array; will print each piece of fruit.

orange apple peach pear


The undef operator can be used to remove all of the values from the array. Once undefined, the array will no longer contain any values.

undef @fruit;


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.