🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #219223

Re: PNews update

#219223
From: Gerry Ford
Date: Mon, 14 Apr 2008 05:11
107 lines
4680 bytes
"Mats Peterson" <matsp555@yahoo.com> wrote in message 
news:FQjMj.5999$R_4.4766@newsb.telia.net...
> If anyone happened to get pnews-20080413.zip, please get it once again.
> I have made a small update to it.
Mats,

I made the download and am interested in writing news clients in perl.  I've 
written this one, (among many others of similar difficulty):
#!/usr/bin/perl -w

use strict;
use Net::NNTP ();

use constant NUMBER_OF_ARTICLES    => 10;
use constant GROUP_NAME        => 'comp.lang.c';
use constant SERVER_NAME    => 'newsgroups.comcast.net';
use constant NNTP_DEBUG        => 0;

my $nntp = Net::NNTP->new(SERVER_NAME, 'Debug' => NNTP_DEBUG) or die;
my $USER = 'mpjensen77@comcast.net';
my $PASS = '';

$nntp->authinfo($USER,$PASS) 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 
RETRIEVE;


    # 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";

# perl perl23.pl 2>text50.txt >text51.txt
# end script, resume comment
Since we have the subject line here at the bottom, instead of printing it, 
we could put it through regex, and if regex likes the string, it gets 
printed else next message.

My question for Mats has to do with the use statements in his client:
use strict;
use Net::NNTP;
use Net::SMTP;
use HTTP::Date qw/time2str str2time/;
use MIME::QuotedPrint qw/encode_qp decode_qp/;
use Encode qw/encode decode/;
use POSIX qw/strftime/;
use File::stat;
use File::Temp qw/:mktemp/;
use Win32::ANSIConsole qw/coninit cls/;

I believe for perl.exe to know what I'm talking about, I would have to 
download these modules.  This isn't as sraightforward as I would like with 
windows, but for a guy at my skill level, I think I could marshall these 
together.  My question goes to this syntax that follows the plain vanilla 
"use" statement:

use File::Temp qw/:mktemp/;
                        ^^^^^^^^

What does it mean?
-- 

"Shopping for toilets isn't the most fascinating way to spend a Saturday
afternoon. But it beats watching cable news."

~~  Booman 

Technical Details
Message-ID: <1208149449_40983@news.newsgroups.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!news-out.newsgroups.com!sp12lax.superfeed.net!not-for-mail
References: <FQjMj.5999$R_4.4766@newsb.telia.net>

Show Full Headers
Complete Article Headers
Message-ID: <1208149449_40983@news.newsgroups.com>
Subject: Re: PNews update
Date: Mon, 14 Apr 2008 00:11:31 -0500
From: "Gerry Ford" <gerry@nowhere.ford>
References: <FQjMj.5999$R_4.4766@newsb.telia.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!news-out.newsgroups.com!sp12lax.superfeed.net!not-for-mail
Lines: 106
Organization: Newsgroups.com
Newsgroups: news.software.readers
X-Proxy-User: $$s_iz$n-74p
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-Report: Please report illegal or inappropriate use to
 <abuse@newsgroups.com>. Forward a copy of ALL headers INCLUDING the body. (DO
 NOT SEND ATTACHMENTS)
X-Comments2: IMPORTANT: Newsgroups.com does not condone, support,
 nor tolerate spam or any illegal or copyrighted postings.
X-Comments: This message was posted through Newsgroups.com
X-Original-Bytes: 4424
X-Original-Lines: 125