Data::Deduper - remove duplicated item from array
use Data::Deduper;
my @data = (1, 2, 3);
my $dd = Data::Deduper->new(
expr => sub { my ($a, $b) = @_; $a eq $b },
size => 3,
data => \@data,
);
# show only 4. because 4 is newer.
for ($dd->dedup(3, 4)) {
print $_;
}
# show 2 3 4 in whole items. max size of items is 3.
for ($dd->data) {
print $_;
}
Data::Deduper removes duplicated items in array. This is useful for fetching RSS/Atom feed continual.
Creates a deduper instance. $expr is specified as expr of grep. $size mean max size of array. $data is initial array.
Reset items. return whole items.
Dedup items. each item in @data will be checked whether is duplicate item. And if the item is not duplicated, it add to the items. Return items added only. Note that return ignore duplicated items.
Return whole items.
Yasuhiro Matsumoto mattn.jp@gmail.com
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.