sub up_file { my ($api, $name, $url, $sum, $reupload) = @_; my $res = $api->api({ action => 'query', prop => 'info', titles => $name }) || return $api->{error}->{details}; my $missing = exists((values %{$res->{query}->{pages}})[0]->{missing}); my $ua = LWP::UserAgent->new( timeout => 25 ); my $response = $ua->get($url); $response = $response->decoded_content if($response->is_success()); if((!$missing && $reupload) || $missing) { $api->edit({ action => 'upload', filename => $name, comment => $sum, text => $sum, file => $response, ignorewarnings => 1 }) || return 'Error with upload file ' . $name . ': ' . $api->{error}->{details}; return 'done'; } return 'File ' . $name . ' exist and $reupload is undefined'; }