perl remove element from array

To remove an element from an array in Perl, you can use the splice function. Here's an example:

my @array = (1, 2, 3, 4, 5);
my $index = 2;  # Index of the element to remove

splice(@array, $index, 1);

# The element at index 2 (value 3) is removed
# Now @array contains (1, 2, 4, 5)

In the example above, we have an array @array with elements (1, 2, 3, 4, 5). We specify the index of the element we want to remove using the variable $index. The splice function is then used to remove one element at the specified index from the array.

Please note that the splice function modifies the original array in place. If you want to keep the original array intact and create a new array without the removed element, you can make a copy of the array before using splice.

I hope this helps!