பயனர்:Sundar/refsync.pl

கட்டற்ற கலைக்களஞ்சியமான விக்கிப்பீடியாவில் இருந்து.
Creative Commons License
Creative Commons Attribution iconCreative Commons Share Alike icon
இந்த ஆக்கம் கிரியேட்டிவ் காமன்சு பெயர்குறித்தல் பகிர்வுரிமப் பதிப்பு 1.0 இன் கீழ் பதியப்பட்டுள்ளது.

உருவாக்கியது: சுந்தர் அனுமதி: கிரியேட்டிவ் காமன்ஸ்

#
#
# உருவாக்கியது: [[பயனர்:Sundar|சுந்தர்]] அனுமதி: [[கிரியேட்டிவ் காமன்ஸ்]]
#
#

use strict;
use utf8;
use WWW::Mechanize;

unless ( @ARGV == 2 ) {
    print STDERR
"பயன்பாடு: perl refsync.pl 'மூலக்கட்டுரைத் தலைப்பு' 'இறுதிக்கட்டுரைத் தலைப்பு'\n";
    exit;
}

my ( $s_l, $d_l ) = ( 'en', 'ta' );

my ( $s_title, $d_title ) = @ARGV;
my $s_url = "http://$s_l.wikipedia.org/w/index.php?title=$s_title&action=edit";
my $d_url = "http://$d_l.wikipedia.org/w/index.php?title=$d_title&action=edit";
my $m          = WWW::Mechanize->new();
$m->env_proxy();
$m->agent_alias('Linux Mozilla');

my $s = $m->get($s_url);
$m->form_number(1) if $m->forms and scalar @{ $m->forms };

# assuming only one text area
my $s_text = $m->field('wpTextbox1');
my @s_refs;
while ( $s_text =~ s/(<\s*ref.+?\/(ref)?\s*>)//s ) {
    push @s_refs, $1;
    print STDERR $1, "\n";
}

my $d = $m->get($d_url);
$m->form_number(1) if $m->forms and scalar @{ $m->forms };
my $d_text = $m->field('wpTextbox1');

foreach my $s_ref(@s_refs) {
	$d_text =~ s/<\s*ref.+?\/(ref)?\s*>/$s_ref/s;
}
print STDERR $d_text;
$m->field('wpTextbox1', $d_text);
$m->field('wpSummary', 'சுந்தரின் ஆய்வு முயற்சி');
$m->click('wpSave');
"https://ta.wikipedia.org/w/index.php?title=பயனர்:Sundar/refsync.pl&oldid=191416" இலிருந்து மீள்விக்கப்பட்டது