Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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;



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.

In reply to Re^4: Text::CSV encoding parse() by slugger415
in thread Text::CSV encoding parse() by slugger415

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, 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:
    & &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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (5)
    As of 2021-01-24 19:32 GMT
    Find Nodes?
      Voting Booth?