- if ($URL =~ /^file:\//) {
- $URL =~ s/^file:\///;
- my $command = "mkdir -p $prefix ; cp $URL $prefix";
- print "$command\n";
- system($command) == 0
- or die "\"$command\" error";
- } else {
- my $command = "wget -c -P $prefix $URL";
- system($command) == 0
- or die "\"$command\" error";
- }
+ my $ua = LWP::UserAgent->new;
+ my $request = HTTP::Request->new(GET => "$URL");
+ my $response = $ua->request($request, \&callback);
+ my ($filename) = reverse (split "/", $URL); # get filename part of the URL
+ open (TEMP, "> $prefix/$filename")
+ || die "Cannot open temporary file: $prefix/$filename\n";
+ print TEMP $cont;
+ close TEMP;