Why not using some CSV specialized module for parsing? You'll avoid this way having to handle 'special' cases like another field separator instead '|' or fields that contain the same char as the field separator etc.
here is a simple example using Text::CSV_XS:
#!/usr/bin/perl -w use strict; use Text::CSV_XS (); use CGI '-autoload'; my $csv = Text::CSV_XS->new({sep_char => '|','escape_char' => '\\',}); print start_html(), $/, start_table(); while(my $line = <DATA>) { $csv->parse($line) or next; print $/, start_Tr(), ( map { td(escapeHTML($_)) } $csv->fields() ), end_Tr(); } print $/, end_table(), $/, end_html(), $/; __DATA__ (foo\|bar)&muci++|5m28888kk|020022992 b"loat++\|<bizbaz>|115m28888kk|020022992333 bloat++"\|<bizbaz>|115m28888kk|020022992333 kk|maka\|paka|111kkio433i|kksk43992s3

--
AltBlue.


In reply to Re: db2html by AltBlue
in thread db2html by straywalrus

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.