The array has lots of data and I need to delete two elements.
Below is the code snippet I am using,
my @array = (1,2,3,4,5,5,6,5,4,9); my $element_o
You could use array slicing instead of splicing. Grep to return the indices you want keep and use slicing:
my @arr = ...; my @indicesToKeep = grep { $arr[$_] ne 'foo' } 0..$#arr; @arr = @arr[@indiciesToKeep];