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...


In reply to Re: Fetch Problem uri by Perlbotics
in thread Fetch Problem uri by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.