User:Polbot/code/Function 1

use strict; use Perlwikipedia;

my $pw=Perlwikipedia->new; $pw->{mech}->agent('Firefox/2.0.0.6'); $pw->set_wiki('en.wikisource.org', 'w'); print "Logging in as Polbot\n"; my $login_status=$pw->login('Polbot','[password]'); die "I can't log in." unless ($login_status == 0);
 * 1) $pw->{debug} = 1;

print "Reading textfile.\n\n"; open(infile, " $rdto\n";

my $wiki = $pw->get_text($rdat); if ($wiki !~ m/\S/) { my $wiki = $pw->get_text($rdto); if ($wiki =~ m/\S/) { print " Creating redirect.\n"; $pw->edit($rdat, "#Redirect $rdto", "#Redirect $rdto"); sleep 1; } else { print " Oops, I can't find the new location.\n"; }	} else { print " Oops, file exists already.\n"; } } close(infile);

print "Done.\n";