ogerault has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I download an excel file from a web site (export) with a perl script and I save it to my disk. Once that doing, I cannot open the file with Excel. When I open the file get with Perl and the one get by hand, they look slightly different but I cannot find what operation I have to do to make Perl saving (getting?) the Excel file in the correct format. I get the file just simply by :
my $response = $ua->get($reportingOgdFormUrl);
if ($response->is_success) {
	open(XLS, ">extract.xls") or die;
	print XLS $response->content;
	close(XLS);
} else {
	die $response->status_line;
}
By analyzing the network traffic, WireShark tells two wired thinks:
Transfer-Encoding: chunked
Content-Type: application/vnd.ms-excel; charset=UTF-8
I tried to decode using UTF-8 and utf8 but it does'nt give any result. I can send the corrupted file (and the correct one) to anyone that would accept to help me. Regards, Olivier

Replies are listed 'Best First'.
Re: Get corrupted Excel file from HTTP
by Corion (Patriarch) on Mar 20, 2009 at 15:06 UTC
      binmode made the file correct, at last.
      Thanks for your help, Corion.

      Olivier