Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
# # WebFetch::PerlMonks.pm - get recent posts on PerlMonks.org # # Copyright (c) 2001 Zenon Zabinski (zdog7@hotmail.com). # All rights reserved. This program is free software; # you can redistribute it and/or modify it under the # same terms as Perl itself. # # Based on the source code of the module # WebFetch::DebianNews and WebFetch::Slashdot. # package WebFetch::PerlMonks; use strict; use vars qw ($VERSION @ISA @EXPORT @Options $parser @bad_nodes @posts +$post); use Exporter; use XML::Parser; use WebFetch; @ISA = qw (Exporter WebFetch); @EXPORT = qw (fetch_main); # configuration parameters $WebFetch::PerlMonks::filename = "perlmonks.html"; $WebFetch::PerlMonks::num_links = 30; $WebFetch::PerlMonks::url = "http://www.perlmonks.org/index.pl?node=ne +west+nodes+xml+generator"; # no user-servicable parts beyond this point # XML stuff $parser = XML::Parser->new ( Handlers => { Start => \&xml_start, End => \&xml_end, Char => \&xml_char }, ); @bad_nodes = ('note', 'user', 'categorized answer'); sub fetch_main { WebFetch::run (); } sub fetch { my ( $self ) = @_; # set parameters for WebFetch routines $self->{url} = $WebFetch::PerlMonks::url; $self->{num_links} = $WebFetch::PerlMonks::num_links; $self->{table_sections} = $WebFetch::PerlMonks::table_sections; # process the links my $content = $self->get; $parser->parse ($$content); my @temp_posts = sort { $$b[1] <=> $$a[1] } @posts; undef @posts; for (my $i = 0; $i < $self->{num_links} && @temp_posts; $i++) { $temp_posts[0][1] =~ s/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{ +2})/$4:$5:$6 $3-$2-$1/; $temp_posts[0][2] = "http://www.perlmonks.org/?node_id=". $tem +p_posts[0][2]; push @posts, shift (@temp_posts); } $self->html_gen ( $WebFetch::PerlMonks::filename, sub { return "<a href=\"".$_[2]."\">".$_[0]."</a> (".$_[1].")" +; }, \@posts ); # export content if --export was specified if ( defined $self->{export}) { $self->wf_export( $self->{export}, [ "title", "date", "url" ], \@posts, "Exported from WebFetch::PerlMonks\n" ."\"title\" is article title\n" ."\"date\" is the date stamp\n" ."\"url\" is article URL" ); } } sub xml_start { my ($p, $el, %atts) = @_; $atts{'title'} = ''; $post = \%atts; } sub xml_end { my ($p, $el) = @_; return unless $el eq 'NODE'; return if grep { m/^$atts{'nodetype'}$/ } @bad_nodes; push @posts, [$post->{'title'}, $post->{'createtime'}, $post->{'no +de_id'}] } sub xml_char { my ($p, $title) = @_; $post->{'title'} .= $title; } 1; __END__ # POD docs follow =head1 NAME WebFetch::PerlMonks - generate a file of recent PerlMonks.org posts =head1 SYNOPSIS >In perl scripts: use WebFetch::PerlMonks; &fetch_main >From the command line: perl -w -MWebFetch::PerlMonks -e "&fetch_main" -- --dir directory =head1 DESCRIPTION This modules grabs the most recent PerlMonks.org posts using XML::Parser and generates a HTML file containing a list of links to those posts. By default, the file is written to perlmonks.html. If that file already exists, a backup will be created at Operlmonks.html before the file is overwritten. =head1 AUTHOR WebFetch was written by Ian Kluft for the Silicon Valley Linux User Group (SVLUG). The WebFetch::PerlMonks module was written by Zenon Zabinski. Send patches or maintenance requests for this module to C<zdog7@hotmail.com>. =head1 SEE ALSO WebFetch =cut

In reply to WebFetch::PerlMonks by zdog

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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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 imbibing at the Monastery: (20)
    As of 2015-07-06 17:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (79 votes), past polls