Posting to Usenet

If some portion of your job requires periodic postings to Usenet—an FAQ listing, for example—the following Perl program can automate the process for you. In the code example, the posted text is read in from a text file, but your input can come from anywhere.

The program shown in Listing 37.8 uses the Net::NNTP module, which is a standard part of the Perl distribution. You can find more documentation on the Net::NNTP module by entering 'perldoc Net::NNTP' at the command line.

Listing 37.8. Posting an Article to Usenet

#!/usr/bin/perl# load the post data into @postopen (POST, "post.file");@post = <POST>;close POST;# import the NNTP moduleuse Net::NNTP;$NNTPhost = 'news';# attempt to connect to the remote host;# print an error ...

Get Ubuntu Unleashed 2013 Edition: Covering 12.10 and 13.04, Eighth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.