From Wikipedia, the free encyclopedia
#!/usr/bin/perl -w
usestrict;
useconstantUSERNAME=>'Tweakbot';
useconstantPASSWORD=>'';# password deleted
useconstantCOOKIES=>'tweakbot.txt';
useconstantEDIT_SUMMARY=>'Tweakbot reporting for duty! (replaced depreciated template)';
useconstantEDIT_MINOR=>1;
useWikipedia;
my$wiki=Wikipedia->new(
'username'=>USERNAME,
'password'=>PASSWORD,
'cookie_file'=>COOKIES,
);
foreachmy$pagename(@ARGV){
my$page=$wiki->get_page($pagename);
my$old_contents=$page->contents;
(my$new_contents=$old_contents)=~s/\{\{ref-section\}\}/==References==\n{{Reflist}}/gi;
unless($new_contentseq$old_contents){
printSTDERR"updating `$pagename'\n";
print"$new_contents\n";
$page->put_contents($new_contents,EDIT_SUMMARY,EDIT_MINOR);
}else{
printSTDERR"nothing to do for `$pagename'\n";
}
}