Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl -Tw use strict; use Net::NNTP (); use constant NUMBER_OF_ARTICLES => 10; use constant GROUP_NAME => 'comp.lang.perl.moderated'; use constant SERVER_NAME => 'my.nntp.server'; use constant NNTP_DEBUG => 0; my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die; my($article_count, $first_article, $last_article) = $nntp->group(GROUP +_NAME) or die; # Which XOVER fields contain Subject: and From:? my $count = 0; my %xover_fmt = map( ($_, $count++), @{ $nntp->overview_fmt or die} ); die unless exists $xover_fmt{'Subject:'}; my $subject_offset = $xover_fmt{'Subject:'}; my $from_offset = $xover_fmt{'From:'}; my(@xover, $start_article); RETRIEVE: while ($#xover+1 < NUMBER_OF_ARTICLES and $last_article >= $ +first_article) { # How many articles do we need? Stop retrieving if we have enough my $articles_required = NUMBER_OF_ARTICLES - ($#xover+1) or last R +ETRIEVE; # Fetch overview information for the articles $start_article = $last_article - ($articles_required-1); $start_article = $start_article > $first_article ? $start_article +: $first_article; my $xover_query = $start_article == $last_article ? $start_article : [$start_article, $last_article]; my $xover_ref = $nntp->xover($xover_query) or die; # Store headers for the articles we've retrieved foreach (sort {$b <=> $a} keys %$xover_ref) { push @xover, $xover_ref->{$_}; } } continue { # Move the pointer forward to fetch previous articles $last_article = $start_article - 1; } # Disconnect from the NNTP server $nntp->quit; print join("\n", map ($_->[$subject_offset].' from '.$_->[$from_offset +], @xover)),"\n";

In reply to NNTP: Most recent articles in a group by tomhukins

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (4)
    As of 2018-05-27 02:26 GMT
    Find Nodes?
      Voting Booth?