Hello, ok here's as short and succinct a sample as I can create.
use Text::CSV;
use CGI;
my($row) = "search/¿Cuales son las partes de una cadena de conexión??s
+cope|ids_jdbc_011.htm|0|1|1|0";
my $csv = Text::CSV->new ({ binary => 1, sep_char => "|" });
my $q = new CGI;
# print the HTML header and start html
print $q->header;
print $q->start_html;
# first, print $row as is
print $q->p("ROW: $row");
# next, parse with $csv
$csv->parse($row);
my @els = $csv->fields;
# print the first field
# this displays the black diamond ? symbol for ¿ and ó
print $q->p("CSV Parse, field 0:",$els[0]);
# split instead
my(@splits) = split('\|',$row);
# print the first element in @splits.
# As noted, this one displays properly in the browser.
print $q->p("split 0:", $splits[0]);
print $q->end_html;
exit;
thanks
======================
UMM, update, when I actually ran the above in my http server I got the opposite results, but with weird errors.
ROW: search/¿Cuales son las partes de una cadena de conexión??scope|
+ids_jdbc_011.htm|0|1|1|0
CSV Parse, field 0: search/¿Cuales son las partes de una cadena de con
+exión??scope
split 0: search/¿Cuales son las partes de una cadena de conexión??sc
+ope
Paint me confused.
In the real script, $row is coming from a @sorted_array from an SQL query. This is getting confusing so maybe I should withdraw my question.
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, 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, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|