in reply to LWP - content_cb

But now i dont know how save these file to my HD

My first attempt would be to write $data (in the callback routine) to a file.  Have you tried that?

Replies are listed 'Best First'.
Re^2: LWP - content_cb
by papaismurf (Novice) on Feb 15, 2012 at 03:51 UTC
    I already tried using

    open $data, ">downloaded.pdf"; close $data;

    A downloaded.pdf its created but appear be empty.

      This doesn't work because (if anything) $data becomes a file handle, but nothing is printed to it.

      The idea would be to open a file handle outside of the callback routine, e.g.

      open my $fh, ">", "downloaded.pdf" or die $!; binmode $fh; # for when you're on a system (like Windows) where line +feeds are translated

      and then within the callback routine, successively print the data to it

      sub callback { my ($data, $response, $protocol) = @_; print $fh $data; ... }

        Really Thx for help, but same thing, a file is created but empyt...