How To Wiki

How to create, read and modify MediaWiki pages in Perl

1,795pages on
this wiki
Add New Page
Talk0 Share
Warning: This page is incomplete, use this article with caution. Please help finish it

Modifying MediaWiki pages in Perl.

There are a number of ways to edit MediaWiki pages in Perl.


CMS::MediaWiki is the main Perl module for reading reading editing MediaWiki pages

Me and this artclie, sitting in a tree, L-E-A-R-N-I-N-G!

Write a pageEdit

sub updatePage {
	my $pageTitle=$_[0];
	my $pageText=$_[1]; 
	my $sleepVar=0;
	my $sleepInterval=2; #in seconds
	#Post the page
	if($pageTitle eq ''){
		print "!!!!!!!!!!!!!!!!!!!!!!!!!!";
		print "!! name error: name empty";
		print "!!!!!!!!!!!!!!!!!!!!!!!!!!";
		$rc = $mw->editPage(   
			title   => "$pageTitle" ,
			section => '' , 
			text    => "$pageText" ,
		  summary => "Updated via  Bot." , #add summary as you wish
		# randome sleep from 0-n in sec
		# to put less load on server
	$sleepVar = rand($sleepInterval);
	system(" sleep $sleepVar");
	print "Page writen...\n";
  • Call sub
    • &writePage($title, $text);

Reading pageEdit

Extracting pages from Archived databaseEdit

Downloading database dump


sub downloadDB {
	my $dbfile=$dbfileLocation;
	my $dbfileOut='';
	my $dbfileType='';

	print "\n# Get the database\n\n";
	$dbfile =~ s/.*\///;
	$dbfileOut = $dbfile;
	$dbfileOut =~ s/\.gz$//;
	$dbfileOut =~ s/\.bz2$//;
	system("rm -f $dbfile"); #removing old file
	system("rm -f $dbfileOut");
	system("wget  $dbfileLocation"); #getting db
	$dbfileType = $dbfile;
	$dbfileType =~ s/.*\.//; #aquiring db file type
	if ( $dbfileType eq 'gz' ) { #extraxting db
		system("gzip -d $dbfile");
	} elsif ( $dbfileType eq 'bz2' ) {
		system("bzip2 -d $dbfile");
	return $dbfileOut;
  • Calling subrutine
    • $dbfile = &downloadDB;
      $dbfile is the variable using for the database file name

link title


To be added

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki