Works for me when I remove the leading whitespace from $url ;-)
Update (2nd question - see below): Change destination filename.
Seems, that the module did not provide a setter-method to change the output_file()?
I'll notify the author later...
This monkeypatch should correct that:
#!/usr/bin/perl
use strict;
use warnings;
use File::Fetch;
my $url="http://www.ekey.net/downloads-475?download=2132cbe2-2fb1-eeff
+-583c-50a39b6aba6c&name=v2_ITA_12-Seiter_Programm_1207_web$
print "Downloading $url\n";
my $ff = File::Fetch->new(uri => $url);
{ #-- ugly patch
package File::Fetch;
print "PATCHED: ", __PACKAGE__, " version $VERSION!\n"; #-- patche
+d line#0
sub output_file {
my $self = shift;
my $file = $self->file;
$self->{_out} = $_[0] if $_[0]; #-- patche
+d line#1
return $self->{_out} if $self->{_out}; #-- patche
+d line#2
$file =~ s/\?.*$//g;
$file ||= $self->file_default;
return $file;
}
}
package main;
print "Before: ", $ff->output_file,"\n";
$ff->output_file("i-probably-violate-terms-of-use.pdf"); #-- or extra
+ct name from URI using a regex
print "After : ", $ff->output_file,"\n";
my $where = $ff->fetch( to => "ekey corpus" ) or $ff->error;
Result:
...
PATCHED: File::Fetch version 0.48!
Before: downloads-475
After : i-probably-violate-terms-of-use.pdf
...
Fixing this problem by use of
parent is left as an exercise to the AM...