sub Download { my $u = shift; # URL (e.g. https://server.org/file.zip) my $p = shift; # output file path/name my $ua = LWP::UserAgent->new; $ua->timeout(10); my $req = HTTP::Request->new('GET', $u); my $res = $ua->request($req); print "Requesting $u\n"; open OUT, ">", $p or die "Can't save output: $!"; binmode(OUT); if ($res->is_success) { print OUT $res->content; close OUT or die "$!"; return 0; } else { print "Could not fetch $u\n"; close OUT or die "$!"; return 1; } }