NAME
App::Rssfilter::Filter::MarkTitle - add some text to the title of an RSS item
VERSION
version 0.07
SYNOPSIS
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>
DESCRIPTION
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.
FUNCTIONS
filter
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.
SEE ALSO
AUTHOR
Daniel Holz <dgholz@gmail.com>
COPYRIGHT AND LICENSE
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.