my $fh; open ($fh, ">", $file) or warn "Unable to open output file for writing: $!"; binmode($fh); print $fh $response->content or warn "Unable to write to output file: $!"; close $fh or warn "Unable to open output file for writing: $!";