🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #219231

Re: PNews update

#219231
From: Mats Peterson
Date: Mon, 14 Apr 2008 08:31
107 lines
4781 bytes
"Gerry Ford" <gerry@nowhere.ford> wrote:
>
> "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?

This is explained in the Exporter documentation, which can be viewed
with the command `perldoc Exporter'. Check the "How to Import" section.

-- 
Mats Peterson
http://www.geocities.com/matsp888/
Technical Details
Message-ID: <tDEMj.6037$R_4.4831@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!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!club-internet.fr!feedme-small.clubint.net!proxad.net!feeder1-1.proxad.net!newspeer1.se.telia.net!se.telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail
References: <FQjMj.5999$R_4.4766@newsb.telia.net> <1208149449_40983@news.newsgroups.com>

Show Full Headers
Complete Article Headers
Message-ID: <tDEMj.6037$R_4.4831@newsb.telia.net>
Subject: Re: PNews update
Date: Mon, 14 Apr 2008 08:31:21 GMT
From: Mats Peterson <matsp555@yahoo.com>
References: <FQjMj.5999$R_4.4766@newsb.telia.net> <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!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!club-internet.fr!feedme-small.clubint.net!proxad.net!feeder1-1.proxad.net!newspeer1.se.telia.net!se.telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail
Newsgroups: news.software.readers
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
User-Agent: PNews
Lines: 107
NNTP-Posting-Host: 213.64.75.194
X-Complaints-To: abuse@telia.com
X-Trace: newsb.telia.net 1208161881 213.64.75.194 (Mon,
NNTP-Posting-Date: Mon, 14 Apr 2008 10:31:21 CEST
Organization: Telia Internet