Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
#!/usr/bin/perl -w use strict; use LWP::Simple; use XML::Parser; use vars qw(%RSS $newsmax %inside $config); $config = "/home/briac/.xchat/getRSS.conf"; IRC::print("** Loading RSS Alert **\n"); IRC::add_command_handler( "RSS", "rss_command_handler" ); sub rss_command_handler { my ( $feed, $count ) = split ( /\s+/, shift () ); $newsmax = $count || 10; do $config; # Error checking if ( !%RSS ) { IRC::print("** Error reading config file\n"); return 1; } if ( !$feed ) { IRC::print("usage: /rss channel [count]\n"); IRC::print( "Available channels: " . join (', ', keys %RSS) . +"\n" ); return 1; } if ( !$RSS{lc($feed)} ) { IRC::print("Channel '$feed' unknown.\n"); IRC::print( "Available channels: " . join (', ', keys %RSS) . +"\n" ); return 1; } my $xml = get( $RSS{lc($feed)} ); if ( !$xml ) { IRC::print("Can't fetch the RSS\n"); return 1; } my $parser = XML::Parser->new( Style => 'Stream' ); $parser->parse($xml); IRC::print("---\n\n"); return 1; } sub StartTag { my $elt = $_[1]; $newsmax-- if $elt eq 'item'; $inside{$elt}++; } sub EndTag { my $elt = $_[1]; IRC::print("\n") if $elt eq 'channel'; $inside{$elt}--; } sub Text { return unless /\S/; return unless $newsmax >= 0; # Channel infos IRC::print("> $_") if ( $inside{channel} && $inside{title} ); IRC::print(" $_") if ( $inside{channel} && $inside{description} +); IRC::print(" ($_)") if ( $inside{channel} && $inside{link} ); # News Items IRC::print("* $_\n") if ( $inside{item} && $inside{title} ); IRC::print(" $_\n") if ( $inside{item} && $inside{link} ); } __END__ # Sample getRSS.conf file %RSS = ( slashdot => 'http://www.slashdot.org/slashdot.rdf', useperl => 'http://use.perl.org/useperl.rdf', perlmonks => 'http://www.perlmonks.org/headlines.rdf', cpan => 'http://search.cpan.org/recent.rdf', theregister => 'http://www.theregister.co.uk/tonys/slashdot.rdf', memepool => 'http://memepool.com/memepool.rss', );

In reply to XChat RSS script by OeufMayo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (12)
    As of 2014-10-21 09:10 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (99 votes), past polls