CMS::MediaWiki - Perl extension for creating, reading and updating MediaWiki pages


  use CMS::MediaWiki;

  my $mw = CMS::MediaWiki->new(
        # protocol => 'https',  # Optional, default is http
        host  => 'localhost',   # Default: localhost
        path  => 'wiki' ,       # Can be empty on 3rd-level domain Wikis
        debug => 0              # Optional. 0=no debug msgs, 1=some msgs, 2=more msgs


Create or update MediaWiki pages. An update of a MediaWiki page can also be reduced to a specific page section. You may update many pages with the same object handle ($mw in the shown example).

You could change the login name between an update. This might be necessary if you would like to update a public page *and* a protected page by the WikiSysop user in just one cycle.

Login example

  if ($mw->login(user => 'Reto', pass => 'yourpass')) {
        print STDERR "Could not login\n";
  else {
        # Logged in. Do stuff ...

Another login example

  $rc = $mw->login(
        protocol => 'https',       # optional, default is http
        host     => 'localhost' ,  # optional here, but wins if (re-)set here
        path     => 'wiki',        # optional here, but wins
        user     => 'Reto' ,       # default: Perlbot
        pass     => 'yourpass' ,

Edit a Wiki page or section

  $rc = $mw->editPage(
        title   => 'Online_Directory:Computers:Software:Internet:Authoring' ,

        section => '' , #  2 means edit second section etc.
                        # '' = no section means edit the full page

        text    => "== Your Section Title ==\nbar foo\n\n",

        summary => "Your summary." , # optional

Get a Wiki page or a section of a Wiki page

  $lines_ref = $mw->getPage(title => 'Perl_driven', section => 1); # omit section to get full page

  # Process Wiki lines ...
  print sprintf('%08d ', ++$i), " $_\n" foreach @$lines_ref;

In general, $rc returns 0 on success unequal 0 on failure.


After a successful call of the editPage function you had the following information available:

  print "Edit time (before) was ", $mw->get('EDIT_TIME_BEFORE'), "\n";
  print "Page title was "        , $mw->get('PAGE_TITLE')      , "\n";
  print "The Wiki name was "     , $mw->get('WIKI_NAME')       , "\n";


None by default.






Reto Schaer, <>


Copyright (C) 2005-2010 by Reto Schaer

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 370:

'=item' outside of any '=over'

Around line 382:

You forgot a '=back' before '=head1'