home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2000 May
/
Chip_2000-05_cd1.bin
/
zkuste
/
Perl
/
ActivePerl-5.6.0.613.msi
/
䆊䌷䈹䈙䏵-䞅䞆䞀㡆䞃䄦䠥
/
_1a5fcbdc50a7cbfa9d1980162d1baff3
< prev
next >
Wrap
Text File
|
2000-03-23
|
28KB
|
706 lines
<HTML>
<HEAD>
<TITLE>News::NNTPClient - Perl 5 module to talk to NNTP server</TITLE>
<LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
<LINK REV="made" HREF="mailto:">
</HEAD>
<BODY>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> News::NNTPClient - Perl 5 module to talk to NNTP server</P></STRONG>
</TD></TR>
</TABLE>
<A NAME="__index__"></A>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
<LI><A HREF="#synopsis">SYNOPSIS</A></LI>
<LI><A HREF="#description">DESCRIPTION</A></LI>
<UL>
<LI><A HREF="#nntpclient commands">NNTPClient Commands</A></LI>
<LI><A HREF="#nntp commands">NNTP Commands</A></LI>
<LI><A HREF="#extended nntp commands">Extended NNTP Commands</A></LI>
</UL>
<LI><A HREF="#author">AUTHOR</A></LI>
<LI><A HREF="#copyright">COPYRIGHT</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="name">NAME</A></H1>
<P>News::NNTPClient - Perl 5 module to talk to NNTP (RFC977) server</P>
<P>
<HR>
<H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
<UL>
<LI>Linux</LI>
<LI>Solaris</LI>
<LI>Windows</LI>
</UL>
<HR>
<H1><A NAME="synopsis">SYNOPSIS</A></H1>
<PRE>
use News::NNTPClient;</PRE>
<PRE>
$c = new News::NNTPClient;
$c = new News::NNTPClient($server);
$c = new News::NNTPClient($server, $port);
$c = new News::NNTPClient($server, $port, $debug);</PRE>
<P>
<HR>
<H1><A NAME="description">DESCRIPTION</A></H1>
<P>This module implements a client interface to NNTP, enabling a Perl 5
application to talk to NNTP servers. It uses the OOP (Object Oriented
Programming) interface introduced with Perl 5.</P>
<P>NNTPClient exports nothing.</P>
<P>A new NNTPClient object must be created with the <EM>new</EM> method. Once
this has been done, all NNTP commands are accessed through this object.</P>
<P>Here are a couple of short examples. The first prints all articles in
the ``test'' newsgroup:</P>
<PRE>
#!/usr/local/bin/perl -w
</PRE>
<PRE>
use News::NNTPClient;</PRE>
<PRE>
$c = new News::NNTPClient;</PRE>
<PRE>
($first, $last) = ($c->group("test"));</PRE>
<PRE>
for (; $first <= $last; $first++) {
print $c->article($first);
}</PRE>
<PRE>
__END__</PRE>
<P>This example prints the body of all articles in the ``test'' newsgroup
newer than one hour:</P>
<PRE>
#!/usr/local/bin/perl -w
</PRE>
<PRE>
require News::NNTPClient;</PRE>
<PRE>
$c = new News::NNTPClient;</PRE>
<PRE>
foreach ($c->newnews("test", time - 3600)) {
print $c->body($_);
}</PRE>
<PRE>
__END__</PRE>
<P>
<H2><A NAME="nntpclient commands">NNTPClient Commands</A></H2>
<P>These commands are used to manipulate the NNTPClient object, and
aren't directly related to commands available on any NNTP server.</P>
<DL>
<DT><STRONG><A NAME="item_new"><EM>new</EM></A></STRONG><BR>
<DD>
Use this to create a new NNTP connection. It takes three arguments, a
hostname, a port and a debug flag. It calls <EM>initialize</EM>. Use an
empty argument to specify defaults.
<P>If port is omitted or blank (``''), looks for environment variable
NNTPPORT, service ``nntp'', or uses 119.</P>
<P>If host is omitted or empty (``''), looks for environment variable
NNTPSERVER or uses ``news''.</P>
<P>Examples:</P>
<PRE>
$c = new News::NNTPClient;
or
$c = new News::NNTPClient("newsserver.some.where");
or
$c = new News::NNTPClient("experimental", 9999);
or
# Specify debug but use defaults.
$c = new News::NNTPClient("", "", 2);</PRE>
<P>Returns a blessed reference, representing a new NNTP connection.</P>
<P></P>
<DT><STRONG><A NAME="item_initialize"><EM>initialize</EM></A></STRONG><BR>
<DD>
Calls <EM>port</EM>, <EM>host</EM>, <EM>connect</EM>, and <EM>response</EM>, in that order.
If any of these fail, initialization is aborted.
<P></P>
<DT><STRONG><A NAME="item_connect"><EM>connect</EM></A></STRONG><BR>
<DD>
Connects to current host/port.
Not normally needed, as the <EM>new</EM> method does this for you.
Closes any existing connection.
Sets the posting status. See the <EM>postok</EM> method.
<P></P>
<DT><STRONG><A NAME="item_host"><EM>host</EM></A></STRONG><BR>
<DD>
Sets the host that will be used on the next connect.
Not normally needed, as the <EM>new</EM> method does this for you.
<P>Without an argument, returns current host.</P>
<P>Argument can be hostname or dotted quad, for example, ``15.2.174.218''.</P>
<P>Returns fully qualified host name.</P>
<P></P>
<DT><STRONG><A NAME="item_port"><EM>port</EM></A></STRONG><BR>
<DD>
Sets the port that will be used on the next connect.
Not normally needed, as the <EM>new</EM> method does this for you.
<P>Without an argument, returns current port.</P>
<P>Argument can be port number or name. If it is a name, it must be a
valid service.</P>
<P>Returns port number.</P>
<P></P>
<DT><STRONG><A NAME="item_debug"><EM>debug</EM></A></STRONG><BR>
<DD>
Sets the debug level.
<P>Without an argument, returns current debug level.</P>
<P>There are currently three debug levels. Level 0, level 1, and level
2.</P>
<P>At level 0 the messages described for level 1 are not produced. Debug
level 0 is a way of turning off messages produced by the default debug
level 1. Serious error messages, such as EOF (End Of File) on the
file handle, are still produced.</P>
<P>At level 1, any NNTP command that results in a result code of 400 or
greater prints a warning message. This is the default.</P>
<P>At level 2, in addition to level 1 messages, status messages are
printed to indicate actions taking place.</P>
<P>Returns old debug value.</P>
<P></P>
<DT><STRONG><A NAME="item_ok"><EM>ok</EM></A></STRONG><BR>
<DD>
Returns boolean status of most recent command. NNTP return codes less
than 400 are considered OK. Not often needed as most commands return
false upon failure anyway.
<P></P>
<DT><STRONG><A NAME="item_okprint"><EM>okprint</EM></A></STRONG><BR>
<DD>
Returns boolean status of most recent command. NNTP return codes less
than 400 are considered OK. Prints an error message for return codes
of 400 or greater unless debug level is set to zero (0).
<P>This method is used internally by most commands, and could be
considered to be ``for internal use only''. You should use the return
status of commands directly to determine pass-fail, or if needed the
<EM>ok</EM> method can be used to check status later.</P>
<P></P>
<DT><STRONG><A NAME="item_message"><EM>message</EM></A></STRONG><BR>
<DD>
Returns the NNTP response message of the most recent command.
<P>Example, as returned by NNTP server version 1.5.11t:</P>
<PRE>
$c->slave;
print $c->message;</PRE>
<PRE>
Kinky, kinky. I don't support such perversions.</PRE>
<P></P>
<DT><STRONG><A NAME="item_code"><EM>code</EM></A></STRONG><BR>
<DD>
Returns the NNTP response code of the most recent command.
<P>Example:</P>
<PRE>
$c->article(1);
print $c->code, "\n";</PRE>
<PRE>
412</PRE>
<P></P>
<DT><STRONG><A NAME="item_postok"><EM>postok</EM></A></STRONG><BR>
<DD>
Returns the post-ability status that was reported upon connection or
after the mode_reader command.
<P></P>
<DT><STRONG><A NAME="item_eol"><EM>eol</EM></A></STRONG><BR>
<DD>
Sets the End-Of-Line termination for text returned from the server.
<P>Returns the old EOL value.</P>
<P>Default is \n.</P>
<P>To set EOL to nothing, pass it the empty string.</P>
<P>To query current EOL without setting it, call with no arguments.</P>
<P>Example:</P>
<PRE>
$old_eol = $c->eol(); # Get original.
$c->eol(""); # Set EOL to nothing.
@article = $c->article(); # Fetch an article.
$c->eol($old_eol); # Restore value.</PRE>
<P></P>
<DT><STRONG><A NAME="item_gmt"><EM>gmt</EM></A></STRONG><BR>
<DD>
Sets GMT mode. Returns old value. To query GMT mode without setting
it, call with no arguments.
<P>A true value means that GMT mode is used in the <EM>newgroups</EM> and
<EM>newnews</EM> functions. A false value means that local time is used.</P>
<P></P>
<DT><STRONG><A NAME="item_fourdigityear"><EM>fourdigityear</EM></A></STRONG><BR>
<DD>
Sets four digit year mode. Returns old value. To query four digit
year mode without setting it, call with no arguments.
<P>A true value means that four digit years are used in the <EM>newgroups</EM>
and <EM>newnews</EM> functions. A false value means that an RFC977
compliant two digit year is used.</P>
<P>This function is available for news servers that implemented four
digit years rather than deal with non-y2k compliment two digit years.
RFC977 does not allow four digit years, and instead chooses the
century closest. I quote:</P>
<PRE>
The closest century is assumed as part of the year (i.e., 86
specifies 1986, 30 specifies 2030, 99 is 1999, 00 is 2000).</PRE>
<P></P>
<DT><STRONG><A NAME="item_version"><EM>version</EM></A></STRONG><BR>
<DD>
Returns version number.
<P>This document represents @(#) $Revision: 0.36 $.</P>
<P></P></DL>
<P>
<H2><A NAME="nntp commands">NNTP Commands</A></H2>
<P>These commands directly correlate to NNTP server commands. They
return a false value upon failure, true upon success. The truth value
is usually some bit of useful information. For example, the <EM>stat</EM>
command returns Message-ID if it is successful.</P>
<P>Some commands return multiple lines. These lines are returned as an
array in array context, and as a reference to an array in scalar
context. For example, if you do this:</P>
<PRE>
@lines = $c->article(14);</PRE>
<P>then @lines will contain the article, one line per array element.
However, if you do this:</P>
<PRE>
$lines = $c->article(14);</PRE>
<P>then $lines will contain a <EM>reference</EM> to an array. This feature is
for those that don't like passing arrays from routine to routine.</P>
<DL>
<DT><STRONG><A NAME="item_mode_reader"><EM>mode_reader</EM></A></STRONG><BR>
<DD>
Some servers require this command to process NNTP client commands.
Sets postok status. See <EM>postok</EM>.
<P>Returns OK status.</P>
<P></P>
<DT><STRONG><A NAME="item_article"><EM>article</EM></A></STRONG><BR>
<DD>
Retrieves an article from the server. This is the main command for
fetching articles. Expects a single argument, an article number or
Message-ID. If you use an article number, you must be in a news
group. See <EM>group</EM>.
<P>Returns the header, a separating blank line, and the body of the
article as an array of lines terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>Examples:</P>
<PRE>
print $c->article('<art1234@soom.oom>');</PRE>
<PRE>
$c->group("test");</PRE>
<PRE>
print $c->article(99);</PRE>
<P></P>
<DT><STRONG><A NAME="item_body"><EM>body</EM></A></STRONG><BR>
<DD>
Expects a single argument, an article number or Message-ID.
<P>Returns the body of an article as an array of lines terminated by the
current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>See <EM>article</EM>.</P>
<P></P>
<DT><STRONG><A NAME="item_head"><EM>head</EM></A></STRONG><BR>
<DD>
Expects a single argument, an article number or Message-ID.
<P>Returns the head of the article as an array of lines terminated by the
current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>See <EM>article</EM>.</P>
<P></P>
<DT><STRONG><A NAME="item_stat"><EM>stat</EM></A></STRONG><BR>
<DD>
Expects a single argument, an article number or Message-ID.
<P>The STAT command is like the ARTICLE command except that it does not
return any text. It can be used to set the ``current article pointer''
if passed an article number, or to validate a Message-ID if passed a
Message-ID.</P>
<P>Returns Message-ID if successful, otherwise returns false.</P>
<P></P>
<DT><STRONG><A NAME="item_last"><EM>last</EM></A></STRONG><BR>
<DD>
The ``current article pointer'' maintained by the server is moved to the
previous article in the current news group.
<P>Returns Message-ID if successful, otherwise returns false.</P>
<P></P>
<DT><STRONG><A NAME="item_next"><EM>next</EM></A></STRONG><BR>
<DD>
The ``current article pointer'' maintained by the server is moved to the
next article in the current news group.
<P>Returns Message-ID if successful, otherwise returns false.</P>
<P></P>
<DT><STRONG><A NAME="item_group"><EM>group</EM></A></STRONG><BR>
<DD>
Expects a single argument, the name of a valid news group.
<P>This command sets the current news group as maintained by the server.
It also sets the server maintained ``current article pointer'' to the
first article in the group. This enables the use of certain other
server commands, such as <EM>article</EM>, <EM>head</EM>, <EM>body</EM>, <EM>stat</EM>,
<EM>last</EM>, and <EM>next</EM>. Also sets the current group in the NNTPClient
object, which is used by the <EM>newnews</EM> and <EM>xindex</EM> commands.</P>
<P>Returns (first, last) in list context, or ``first-last'' in scalar
context, where first and last are the first and last article numbers
as reported by the group command. Returns false if there is an error.</P>
<P>It is an error to attempt to select a non-existent news group.</P>
<P>If the estimated article count is needed, it can be extracted from the
message. See <EM>message</EM>.</P>
<P></P>
<DT><STRONG><A NAME="item_list"><EM>list</EM></A></STRONG><BR>
<DD>
Accepts one optional argument that can be used indicate the type of
list desired. List type depends on server.
<P>With an argument of ``active'' or with no arguments, this command
returns a list of valid newsgroups and associated information. The
format is:</P>
<PRE>
group last first p</PRE>
<P>where group is the news group name, last is the article number of the
last article, first is the article number of the first article, and p
is flag indicating if posting is allowed. A 'y' flag is an indication
that posting is allowed.</P>
<P>Other possible arguments are: newsgroups, distributions, subscriptions
for B-News, and active.times, distributions, distrib.pats, newsgroups,
overview.fmt for INN.</P>
<P>Returns an array of lines terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P></P>
<DT><STRONG><A NAME="item_newgroups"><EM>newgroups</EM></A></STRONG><BR>
<DD>
Expects at least one argument representing the date/time in seconds,
or in ``YYYYMMDD HHMMSS [GMT]'' format. The GMT part is optional. If
you wish to use GMT with the seconds format, first call <EM>gmt</EM>.
Remaining arguments are used as distributions.
<P>Example, print all new groups in the ``comp'' and/or ``news'' hierarchy as
of one hour ago:</P>
<PRE>
print $c->newgroups(time() - 3600, "comp", "news");</PRE>
<P>Returns list of new news group names as an array of lines terminated
by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P></P>
<DT><STRONG><A NAME="item_newnews"><EM>newnews</EM></A></STRONG><BR>
<DD>
Expects one, two, or more arguments.
<P>If the first argument is a group name, it looks for new news in that
group, and the date/time is the second argument. If the first
argument represents the date/time in seconds or in ``YYYYMMDD HHMMSS
[GMT]'' format, then the group is is last group set via the <EM>group</EM>
command. If no <EM>group</EM> command has been issued then the group is ``*'',
representing all groups. If you wish to use GMT in seconds format for
the time, first call <EM>gmt</EM>. Remaining arguments are use to restrict
search to certain distribution(s).</P>
<P>Returns a list of Message-IDs of articles that have been posted or
received since the specified time.</P>
<P>Examples:</P>
<PRE>
# Hour old news in news group "test".
$c->newnews("test", time() - 3600);
or
# Hour old in all groups.
$c->newnews(time() - 3600);
or
$c->newnews("*", time() - 3600);
or
# Hour old news in news group "test".
$c->group("test");
$c->newnews(time() - 3600);</PRE>
<P>The group argument can include an asterisk ``*'' to specify a range news
groups. It can also include multiple news groups, separated by a
comma ``,''.</P>
<P>Example:</P>
<PRE>
$c->newnews("comp.*.sources,alt.sources", time() - 3600);</PRE>
<P>An exclamation point ``!'' may be used to negate the selection of
certain groups.</P>
<P>Example:</P>
<PRE>
$c->newnews("*sources*,!*.d,!*.wanted", time() - 3600);</PRE>
<P>Any additional distribution arguments will be concatenated together
and send as a distribution list. The distribution list will limit
articles to those that have a Distribution: header containing one of
the distributions passed.</P>
<P>Example:</P>
<PRE>
$c->newnews("*", time() - 3600, "local", "na");</PRE>
<P>Returns Message-IDs of new articles as an array of lines terminated by
the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P></P>
<DT><STRONG><A NAME="item_help"><EM>help</EM></A></STRONG><BR>
<DD>
Returns any server help information. The format of the information is
highly dependent on the server, but usually contains a list of NNTP
commands recognized by the server.
<P>Returns an array of lines terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P></P>
<DT><STRONG><A NAME="item_post"><EM>post</EM></A></STRONG><BR>
<DD>
Post an article. Expects data to be posted as an array of lines. Most
servers expect, at a minimum, Newsgroups and Subject headers. Be sure
to separate the header from the body with a neck, er blank line.
<P>Example:</P>
<PRE>
@header = ("Newsgroups: test", "Subject: test", "From: tester");
@body = ("This is the body of the article");</PRE>
<PRE>
$c->post(@header, "", @body);</PRE>
<P>There aren't really three arguments. Perl folds all arguments into a
single list. You could also do this:</P>
<PRE>
@article = ("Newsgroups: test", "Subject: test", "From: tester", "", "Body");
$c->post(@article);</PRE>
<P>or even this:</P>
<PRE>
$c->post("Newsgroups: test", "Subject: test", "From: tester", "", "Body");</PRE>
<P>Any ``\n'' characters at the end of a line will be trimmed.</P>
<P>Returns status.</P>
<P></P>
<DT><STRONG><A NAME="item_ihave"><EM>ihave</EM></A></STRONG><BR>
<DD>
Transfer an article. Expects an article Message-ID and the article to
be sent as an array of lines.
<P>Example:</P>
<PRE>
# Fetch article from server on $c
@article = $c->article($artid);
</PRE>
<PRE>
# Send to server on $d
if ($d->ihave($artid, @article)) {
print "Article transfered\n";
} else {
print "Article rejected: ", $d->message, "\n";
}</PRE>
<P></P>
<DT><STRONG><A NAME="item_slave"><EM>slave</EM></A></STRONG><BR>
<DD>
Doesn't do anything on most servers. Included for completeness.
<P></P>
<DT><STRONG><A NAME="item_DESTROY"><EM>DESTROY</EM></A></STRONG><BR>
<DD>
This method is called whenever the the object created by
News::NNTPClient::new is destroyed. It calls <EM>quit</EM> to close the
connection.
<P></P>
<DT><STRONG><A NAME="item_quit"><EM>quit</EM></A></STRONG><BR>
<DD>
Send the NNTP quit command and close the connection. The connection
can be then be re-opened with the connect method. Quit will
automatically be called when the object is destroyed, so there is no
need to explicitly call <EM>quit</EM> before exiting your program.
<P></P></DL>
<P>
<H2><A NAME="extended nntp commands">Extended NNTP Commands</A></H2>
<P>These commands also directly correlate NNTP server commands, but are
not mentioned in RFC977, and are not part of the standard. However,
many servers implement them, so they are included as part of this
package for your convenience. If a command is not recognized by a
server, the server usually returns code 500, command unrecognized.</P>
<DL>
<DT><STRONG><A NAME="item_authinfo"><EM>authinfo</EM></A></STRONG><BR>
<DD>
Expects two arguments, user and password.
<P></P>
<DT><STRONG><A NAME="item_date"><EM>date</EM></A></STRONG><BR>
<DD>
Returns server date in ``YYYYMMDDhhmmss'' format.
<P></P>
<DT><STRONG><A NAME="item_listgroup"><EM>listgroup</EM></A></STRONG><BR>
<DD>
Expects one argument, a group name. Default is current group.
<P>Returns article numbers as an array of lines terminated by the current
EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P></P>
<DT><STRONG><A NAME="item_xmotd"><EM>xmotd</EM></A></STRONG><BR>
<DD>
Expects one argument of unix time in seconds or as a string in the
form ``YYYYMMDD HHMMSS''.
<P>Returns the news servers ``Message Of The Day'' as an array of lines
terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>For example, the following will always print the message of the day,
if there is any:</P>
<PRE>
print $c->xmotd(1);
NNTP Server News2</PRE>
<PRE>
News administrator is Joseph Blough <joeblo@news.foo.com></PRE>
<P></P>
<DT><STRONG><A NAME="item_xgtitle"><EM>xgtitle</EM></A></STRONG><BR>
<DD>
Expects one argument of a group pattern. Default is current group.
<P>Returns group titles an array of lines terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>Example:</P>
<PRE>
print $c->xgtitle("bit.listserv.v*");</PRE>
<PRE>
bit.listserv.valert-l Virus Alert List. (Moderated)
bit.listserv.vfort-l VS-Fortran Discussion List.
bit.listserv.vm-util VM Utilities Discussion List.
bit.listserv.vmesa-l VM/ESA Mailing List.
bit.listserv.vmslsv-l VAX/VMS LISTSERV Discussion List.
bit.listserv.vmxa-l VM/XA Discussion List.
bit.listserv.vnews-l VNEWS Discussion List.
bit.listserv.vpiej-l Electronic Publishing Discussion</PRE>
<P></P>
<DT><STRONG><A NAME="item_xpath"><EM>xpath</EM></A></STRONG><BR>
<DD>
Expects one argument of an article Message-ID. Returns the path name
of the file on the server.
<P>Example:</P>
<PRE>
print print $c->xpath(q(<43bq5l$7b5@news.dtc.hp.com>))'
hp/test/4469</PRE>
<P></P>
<DT><STRONG><A NAME="item_xhdr"><EM>xhdr</EM></A></STRONG><BR>
<DD>
Fetch header for a range of articles. First argument is name of
header to fetch. If omitted or blank, default to Message-ID. Second
argument is start of article range. If omitted, defaults to 1. Third
argument is end of range. If omitted, defaults to ``''. The second
argument can also be a Message-ID.
<P>Returns headers as an array of lines terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>Examples:</P>
<PRE>
# Fetch Message-ID of article 1.
$c->xhdr();</PRE>
<PRE>
# Fetch Subject of article 1.
$c->xhdr("Subject");</PRE>
<PRE>
# Fetch Subject of article 3345.
$c->xhdr("Subject", 3345);</PRE>
<PRE>
# Fetch Subjects of articles 3345-9873
$c->xhdr("Subject", 3345, 9873);</PRE>
<PRE>
# Fetch Message-ID of articles 3345-9873
$c->xhdr("", 3345,9873);</PRE>
<PRE>
# Fetch Subject for article with Message-ID
$c->xhdr("Subject", '<797t0g$25f10@foo.com>');</PRE>
<P></P>
<DT><STRONG><A NAME="item_xpat"><EM>xpat</EM></A></STRONG><BR>
<DD>
Fetch header for a range of articles matching one or more patterns.
First argument is name of header to fetch. If omitted or blank,
default to Subject. Second argument is start of article range. If
omitted, defaults to 1. Next argument is end of range. Remaining
arguments are patterns to match. Some servers use ``*'' for wildcard.
<P>Returns headers as an array of lines terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>Examples:</P>
<PRE>
# Fetch Subject header of article 1.
$c->xpat();</PRE>
<PRE>
# Fetch "From" header of article 1.
$c->xpat("From");</PRE>
<PRE>
# Fetch "From" of article 3345.
$c->xpat("From", 3345);</PRE>
<PRE>
# Fetch "From" of articles 3345-9873 matching *foo*
$c->xpat("From", 3345, 9873, "*foo*");</PRE>
<PRE>
# Fetch "Subject" of articles 3345-9873 matching
# *foo*, *bar*, *and*, *stuff*
$c->xpat("", 3345,9873, qw(*foo* *bar* *and* *stuff*));</PRE>
<P></P>
<DT><STRONG><A NAME="item_xover"><EM>xover</EM></A></STRONG><BR>
<DD>
Expects an article number or a starting and ending article number
representing a range of articles.
<P>Returns overview information for each article as an array of lines
terminated by the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P>Xover generally returns items separated by tabs. Here is an example
that prints out the xover fields from all messages in the ``test'' news
group.</P>
<PRE>
#!/usr/local/bin/perl</PRE>
<PRE>
require News::NNTPClient;</PRE>
<PRE>
$c = new News::NNTPClient;</PRE>
<PRE>
@fields = qw(numb subj from date mesg refr char line xref);</PRE>
<PRE>
foreach $xover ($c->xover($c->group("test"))) {
%fields = ();
@fields{@fields} = split /\t/, $xover;
print map { "$_: $fields{$_}\n" } @fields;
print "\n";
}</PRE>
<PRE>
__END__
#
=item I<xthread></PRE>
<P>Expects zero or one argument. Value of argument doesn't matter. If
present, <EM>dbinit</EM> command is sent. If absent, <EM>thread</EM> command is
sent.</P>
<P>Returns binary data as a scalar value.</P>
<P>Format of data returned is unknown at this time.</P>
<P></P>
<DT><STRONG><A NAME="item_xindex"><EM>xindex</EM></A></STRONG><BR>
<DD>
Expects one argument, a group name. If omitted, defaults to the group
set by last <EM>group</EM> command. If there hasn't been a group command,
it returns an error;
<P>Returns index information for group as an array of lines terminated by
the current EOL.</P>
<P>In scalar context a reference to the array is returned instead of the
array itself.</P>
<P></P>
<DT><STRONG><A NAME="item_xsearch"><EM>xsearch</EM></A></STRONG><BR>
<DD>
Expects a query as an array of lines which are sent to the server,
much like post. Returns the result of the search as an array of lines
or a reference to same.
<P>Format of query is unknown at this time.</P>
<P></P></DL>
<P>
<HR>
<H1><A NAME="author">AUTHOR</A></H1>
<P>Rodger Anderson <<A HREF="mailto:rodger@boi.hp.com">rodger@boi.hp.com</A>></P>
<P>
<HR>
<H1><A NAME="copyright">COPYRIGHT</A></H1>
<P>Copyright 1995 Rodger Anderson. All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.</P>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
<STRONG><P CLASS=block> News::NNTPClient - Perl 5 module to talk to NNTP server</P></STRONG>
</TD></TR>
</TABLE>
</BODY>
</HTML>