in reply to Re^4: objects and duplicates
in thread objects and duplicates
I didn't express myself clearly: I said flag for $record->duplicate, but in fact it should hold the number of times the sentence is duplicate, so it's more a count than a flag.In that case your object approach isn't modeling the problem correctly - storing the number of duplicates in the Entry object doesn't make sense. Your original approach is better, but I'd do it this way:
ormy %count; for (@items) { $count{$_}++ } my @dups = grep { $count{$_} > 1 } @items;
In each case $count{$sentence} contains the number of occurrences of $sentence. Will this work for you?my (%count, @dups); for (@items) { $count{$_}++ == 1 && push(@dups, $_) }
|
|---|