App::Rssfilter::Match::Category - match an RSS item by category
version 0.04
use App::Rssfilter::Match::Category; use Mojo::DOM; my $rss = Mojo::DOM->new( <<"End_of_RSS" ); <?xml version="1.0" encoding="UTF-8"?> <rss> <channel> <item> <title>Jumping jackrabbit smash long jump record</title> <category>Sport:leporine</category> </item> <item> <title>Online poll proves programmers cool, successful</title> <category>Internet:very_real_and_official</category> </item> </channel> </rss> End_of_RSS print $_, "\n" for $rss->find( 'item' )->grep( sub { App::Rssfilter::Match::Category::match( shift, 'Sport' ) ) { } ); # or with an App::Rssfilter::Rule use App::Rssfilter::Rule; App::Rssfilter::Rule->new( condition => 'Category[Sport]', action => sub { print shift->to_xml, "\n" }, )->constrain( $rss ); # either way, prints # <item> # <title>Jumping jackrabbit smash long jump record</title> # <category>Sport:leporine</category> # </item>
This module will match an RSS item if it has one or more specific category.
my $item_has_category = App::Rssfilter::Match::Category::match( $item, @categories );
Returns true if $item has a category which matches any of @categories. Since some RSS feeds specify categories & subcategories as 'main category:subcategory', elements of @categories can be:
$item
@categories
main category:subcategory
category - this category, with any subcategory
category
category:subcategory - only this category with this subcategory
category:subcategory
:subcategory - any category with a matching subcategory
:subcategory
App::Rssfilter
App::Rssfilter::Rule
Daniel Holz <dgholz@gmail.com>
This software is copyright (c) 2013 by Daniel Holz.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install App::Rssfilter, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Rssfilter
CPAN shell
perl -MCPAN -e shell install App::Rssfilter
For more information on module installation, please visit the detailed CPAN module installation guide.