Text::Summary::MediaWiki - Produce a short summary from MediaWiki markup


    use Text::Summary::MediaWiki;

    my $s = Text::Summary::MediaWiki->new(
      url => "", # Trailing / is required
      get => sub {
        my($url) = @_;
        # return markup of page at URL

    print $s->get("Perl");


Produces short summaries from MediaWiki markup. This has been mostly tested with Wikipedia but this should work for any wiki using MediaWiki markup.

Note that making requests to Wikipedia for each page is considered rather rude, if you need a high query volume use a local database dump (I use Parse::MediaWikiDump).



The new method takes a parameter hash containing the following:

  • url

    Required, the URL used to identify the instance of MediaWiki to produce summaries for. This should be the base path to the instance.

  • get

    Required, a callback to fetch the actual text, this is required so the code can get additional pages if redirected.

  • redirect_limit

    Optional, a limit for redirection, default 5.

  • approx_length

    Optional, approximate length of summary to produce (in characters), default 200.


Given the name of an article fetches it and generates a summary.

If called in array context returns the summary and the URL it can be found at.


Generates a summary from text in MediaWiki format.


David Leadbeater <dgl at>


Copyright 2006 David Leadbeater, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.