in reply to removing duplicated elements from array, with a difference
Next, remove any element whose item_count != 1:my %item_count; %item_count{$_}++ foreach (@array);
--Dave.@result = grep {$item_count{$_} == 1} @array;
Update: for the duplicate sub-pattern problem:
my %item_count; %item_count{$_}++ for grep {/pattern/} @array @result = grep {$item_count{$_} <= 1} @array;
Update 2: to avoid the uninitialized value warning:
@result = grep {($item_count{$_}||0) <= 1} @array;
|
|---|