App-Rssfilter
view release on metacpan or search on metacpan
lib/App/Rssfilter/Match/Duplicates.pm view on Meta::CPAN
# ABSTRACT: match an RSS item which has been seen before
use strict;
use warnings;
package App::Rssfilter::Match::Duplicates;
{
$App::Rssfilter::Match::Duplicates::VERSION = '0.07';
}
use Method::Signatures;
use Try::Tiny;
func match ( $item ) {
use feature 'state';
state %prev;
my @matchables =
map { s/ [?] .* \z //xms; $_ }
grep { $_ ne '' }
$item->find( 'guid, link' )->pluck( 'text' )->each;
my $res = grep { defined } @prev{ @matchables };
@prev{ @matchables } = ( 1 ) x @matchables;
return 0 < $res;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
App::Rssfilter::Match::Duplicates - match an RSS item which has been seen before
=head1 VERSION
version 0.07
=head1 SYNOPSIS
use App::Rssfilter::Match::Duplicates;
use Mojo::DOM;
my $first_rss = Mojo::DOM->new( <<"End_of_RSS" );
<?xml version="1.0" encoding="UTF-8"?>
<rss>
<channel>
<item>
<link>http://rss.slashdot.org/~r/Slashdot/slashdot/~6/gu7UEWn8onK/is-typing-tiring-your-toes</link>
<description>type with toes for tighter tarsals</description>
</item>
<item>
<link>http://rss.slashdot.org/~r/Slashdot/slashdot/~9/lloek9InU2p/new-planet-discovered-on-far-side-of-sun</link>
<description>vulcan is here</description>
</item>
</channel>
</rss>
End_of_RSS
my $second_rss = Mojo::DOM->new( <<"End_of_RSS" );
<?xml version="1.0" encoding="UTF-8"?>
<rss>
<channel>
<item>
<link>http://rss.slashdot.org/~r/Slashdot/slashdot/~3/mnej39gJa9E/new-rocket-to-visit-mars-in-60-days</link>
<description>setting a new speed record</description>
( run in 1.545 second using v1.01-cache-2.11-cpan-39bf76dae61 )