in reply to Re: Can't remove the the duplicate element when it's the last one in the array
in thread Can't remove the the duplicate element when it's the last one in the array

my %seen; for ( my $i = 0; $i < scalar @arr; $i++){ splice @arr, $i--, 1 if $seen{$arr[ $i]}++; }
can be simplified to
my %seen; for ( my $i = @arr; $i--; ){ splice @arr, $i, 1 if $seen{$arr[$i]}++; }
But the following will be much faster:
my %seen; @arr = grep !$seen{$_}++, @arr;