this does not work; lines end up being of different length and the colours disappear. To simplify my task to the minimum, imagine, still inside a CGI script you have 2 strings:
my $a: "ABCDEFGHI" my $b: "<b>ABC</b>DEFGHI"
I want to print this 2 strings with 4 characters per line and in the second string ABC has to be in bold; If I use my method, or your method, this is what I get:
$a: ABCD EFGH I $b: <b>A BC</ b>DE FGHI
I want the bold tags ingored in the characters counts: So:
$a: ABCD EFGH I $b: <b>ABC</b>D EFGH I
Also as I said, when I try your code it also does something with the coloured tags I used; Note: in this example I am using bold tag to make it shorter, in my scrip I am using a span class as shown. I hope it is more clear. I do not know in advance where the position it is: i need an universal solution which can print something with the same number of characters per line, basically ignoring the tags in the counts.

In reply to Re^2: Print N characters per line in Cgi Script with Html Tags by Diesel
in thread Print N characters per line in Cgi Script with Html Tags by Diesel

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.