saving a pdf image to file

can you give me an idea for saving a pdf image to file.
i tried this way,
 open(outputfile, ">test1.pdf" ) or die "Cannot create $file_path: $!";
 print outputfile "$data";
where $data is the result of a http request.
this gave me only a page with no data.
hope you can guide me the rightway.
Who is Participating?
how exactly did you get $data?
it's quite unnecessary to put $data in quotes.
if you're on windows, it's advisable to add "binmode outputfile;" right after the "open()".
minor stylistic recommendation: filehandles should either be in full caps, or you should use a private variable to hold it:

    open my $out, ">test1.pdf" or die "Cannot create $file_path: $!";
    binmode $out;
    print $out $data;
    close $out;
Why does it say on top "You may not collaborate on this question"

If you are getting the PDF via http, then just do:

use LWP::Simple;
getstore("","/path/to/test1.pdf") or die "Can not retrieve test1.pdf $!\n";
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.