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
Delete all occurrences of 'something' if array.
Based on SquareCog answer's:
my @arr = ('1','2','3','4','3','2', '3','4','3');
my @dix = grep { $arr[$_] eq '4' } 0..$#arr;
my $o = 0;
for (@dix) {
splice(@arr, $_-$o, 1);
$o++;
}
print join("\n", @arr);
Each time we remove index from @arr, the next correct index to delete will be $_-current_loop_step.