User talk:Rich Farmbrough/perl-hack

use Mediawiki::API; $user="Rich Farmbrough"; $password="YourPasswordHere";

my $mw = MediaWiki::API->new; $mw->{config}->{api_url} = 'http://en.wikipedia.org/w/api.php';
 * 1) init the wiki object

$mw->login( { lgname => $user, lgpassword => $password } )
 * 1) log in to the wiki
 * die $mw->{error}->{code} . ': ' . $mw->{error}->{details};


 * 1) init the Second wiki object

my $t_mw = MediaWiki::API->new; $t_mw->{config}->{api_url} = 'http://ne.wikipedia.org/w/api.php';

$t_mw->login( { lgname => $user, lgpassword => $password } )
 * 1) log in to the wiki
 * die $t_mw->{error}->{code} . ': ' . $t_mw->{error}->{details};

open FILE, "<:utf8","list.txt"; while (<>){ chomp;

$title=$_; if ((length ($title)) < 6) {next} print "$title\n"; # see what's happening my $page = $mw->get_page( { title => $title } ); $text=$page -> {'*'}; if ((length ($text)) == 0) {next} # if the page is empty (or doesn't exist) skip

$t_mw->edit( {         action => 'edit',          title => $title,          text => $text,          summary => 'Copy template from en:' } ) || die $t_mw->{error}->{code}. ': ' . $t_mw->{error}->{details}; }
 * 1)          basetimestamp => $timestamp, \ to avoid edit conflicts