News::Search - Usenet news searching toolkit


  use News::Search;

  my $ns = News::Search->new();

  my %newsarticles = $ns->SearchNewsgroups;


News::Search searches Usenet news postings.

It can be used to search local news groups that google doesn't cover. Or, even for news groups that are covered by google, it can give you all the hits in one file, in the format that you prescribed.

You can also use the provided news-search in cron to watch specific news groups for specific criteria and mail you reports according to the interval you set.



Initialize the object.

  my $searcher = News::Search->new();


  my $searcher = News::Search->new( {} );

which are the same as:

  my $searcher = News::Search->new( {
     nntp_server => 'news',
     msg_headers => 'Date|From',        # + Subject, which is always printed
     msg_limit   => 200,
     verbose     => 0,
     on_group    => \&default_group_handler,
     on_message  => \&default_message_handler,
  } );

What shown above are default settings. Any of the %config_param attribute can be omitted when calling the new method.

The new is the only class method. All the rest methods are object methods.

Object attributes

The following object attributes are accessible.

  • nntp_server([set_val])

    The nntp server to search.

  • msg_headers([set_val])

    Message headers to print.

  • msg_limit([set_val])

    Maximum number of posts to search (not return).

  • verbose([set_val])

    Be verbose.

  • on_group([set_val])

    Handler for group starts. Refer to news-search for the example.

  • on_message([set_val])

    Handler for news message. Refer to news-search for the example.

Provide the set_val to change the attribute, omitting it to retrieve the attribute value. E.g.,


Object method: search_for($array_ref)


Command line parameter handling. Refer to news-search section "command line arguments" for details.

Object method: SearchNewsgroups()

Search the given newsgroups with the given criteria:

  my %newsarticles = $ns->SearchNewsgroups;

  foreach my $article (values %newsarticles) {
    # deal with  $article->{"SUBJECT"}, @{$article->{"HEADER"}})
    #  and $article->{"BODY"}

Refer to news-search for usage example.




Please report any bugs or feature requests to bug-news-search at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc News::Search

You can also look for information at:


SUN, Tong <suntong at>


Copyright 2003-2008 Tong Sun, all rights reserved.

This program is released under the BSD license.