I am using File::Fetch in a Perl script. How can I get File::Fetch to store a file to be downloaded in a specified file?
I have tried:
use File::Fetch;
my $ff = File::Fetch->new(uri => 'http://stackoverflow.com/users/63550');
#my $where = $ff->fetch() or die $ff->error; # Creates a file named "63550".
my $where = $ff->fetch(to => 'SO.html'); # Creates a subfolder named SO.html with a file named "63550" in it.
A workaround would be to rename the file after download, but is it possible to specify the file name immediately?
Test platform:
-
ActiveState Perl 64 bit. From
perl -v:v5.10.0 built for MSWin32-x64-multi-thread Binary build 1004 [287188] provided by ActiveState. - Windows XP.
Looking at the source code, the only way seems to be making a subclass and overriding the
output_filemethod. I guess the author would accept a patch that makesoutput_filea read/write property, so that it can be changed at run-time.