in reply to Re: Problem in mirror method
in thread Problem in mirror method

Sorry Corion i forget to mention file name, I am getting filename from http::response

$res=$mech->res(); $filename=$res->filename(); # it has current web page filename

The file name is not empty but i'm getting this error , Any Idea about this

Replies are listed 'Best First'.
Re^3: Problem in mirror method
by Corion (Patriarch) on May 26, 2016 at 06:40 UTC

    What makes you so certain that $filename is not empty?

    Does your program work if you hardcode the output filename?

    Did you print $filename just before your call to ->mirror()?

      I have checked before mirror that the filename is not empty

      filename is FNMA_2016C01_RMT.pdf link updated...

        You did not tell us whether your program works if you hardcode $filename to a fixed value. This would help us determine whether the problem is with the value of $filename or somewhere else in the program.

        Please do not post small snippets of your program that don't work stand-alone. Reduce your program to an example of about 20 lines that still is self-contained and is runnable by us and which still exhibits the problem.

        My bet still is that you are extracting an invalid or empty filename, but you're not showing us how $filename gets populated.

        If you want to help us help you better, please follow the steps outlined above in Basic debugging checklist and in my replies above. All of the steps are necessary.

        ...and it prints 'link updated...' like it should, right?

        You call the mirror method from the Module LWP::UserAgent.pm/WWW::Mechanize:

        Take a look what happens to the $file parameter:
        sub mirror { my($self, $url, $file) = @_; my $tmpfile = "$file-$$"; rename( $tmpfile, $file ) or die "Cannot rename '$tmpfile' to '$fi +le': $!\n";
        There have to be an empty string somewhere.