App::Rssfilter::Filter::MarkTitle - add some text to the title of an RSS item
version 0.07
use App::Rssfilter::Filter::MarkTitle; use Mojo::DOM; my $rss = Mojo::DOM->new( <<"End_of_RSS" ); <?xml version="1.0" encoding="UTF-8"?> <rss> <channel> <item><title>it's hi time</title><description>hi</description></item> <item><title>here we are again</title><description>hello</description></item> </channel> </rss> End_of_RSS $rss->find( 'item' )->each( sub { my $item = shift; if( $item =~ /hello/ ) { App::Rssfilter::Filter::MarkTitle::filter( $item, 'HELLO' ); } } ); # or with an App::Rssfilter::Rule use App::Rssfilter::Rule; App::Rssfilter::Rule->new( condition => sub { shift =~ m/hello/xms }, action => 'MarkTitle[HELLO]', )->constrain( $rss ); # either way print $rss->to_xml; # <?xml version="1.0" encoding="UTF-8"?> # <rss> # <channel> # <item><title>it's hi time</title><description>hi</description></item> # <item><title>HELLO - here we are again</title><description>hello</description></item> # </channel> # </rss>
This module will add some uppercase text to the title of a Mojo::DOM element. Use this module instead of App::Rssfilter::Filter::DeleteItem when you wish to verify that your matchers are working correctly, as MarkTitle will simply mark the title of matched items with a specific string, or the name of the matching module.
App::Rssfilter::Filter::filter( $item, $matcher, $explicit_prefix )
Prefixes $item's title with $explicit_prefix (or, if not specified, $matcher) in uppercase. When called from "constrain" in App::Rssfilter::Rule, $matcher will be set to the nice name of the rule's condition, and $explicit_prefix will be the first bracketed argument.
$item
$explicit_prefix
$matcher
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.