I am using a perl script to obtain some information from a web page. I use WWW::Mechanize to navigate through the web and finally send the POST request which allows the script to download the CSV file that I want. The code for the POST request and file storage looks like this:

$req = HTTP::Request->new(POST => $POST_URL2);
$req->content_type('application/x-www-form-urlencoded');
$req->content("t_date_from=01.12.2008&t_date_to=30.12.2008&c_date_create=on&d_prog_name=0&d_status=3001&d_accounting_currency=1&d_screen_file=1&b_save=Actualizar+estad%EDsticas");
$req->referer($referer2);
$mech->request($req);


open(OUTFILE, ">$outfile");#the output file is output.csv

print OUTFILE $mech->response->content();

close(OUTFILE);


This part works fine and I get the CSV file. In this file, there is a lot of information that I don't need so I parse it with another script that writes the final result in an excel file (using Spreadsheet::WriteExcel).

My problem is that any information coming from the former CSV file appears in the excel sheet with a wrong format which is not plain text (there are extra white spaces between the letters).


Is there any way to change the format and force the Mechanize to drop the information in a plain text? Am I doing something wrong?

Any help would be appreciated a lot.

Thanks in advance,
MIK

In reply to wrong encoding using WWW::Mechanize by panchuloguay

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.