#replace my @newarray = grep {$_ !=$element} @array; #remove the element #with splice @array, $index, 1; #remove item from array; # and remove this. No need as the array has been modified. # @array = @newarray; #reset the array