Hi all

I've got the following issue:

I've got a html table that has a fixed with, given bij a html-template tag from within perl.
In this tablem, i show some user-information, like an email adreds from the user eg:
<table width="<!--TMPL_VAR NAME=table_width -->"<tr><td>youremailadress@domain.com</td></table>
Now if the table is too small, the email has to be broken into pieces. On this moment, i use a function breakLine, and i estimate the width of the mail:
sub breakLine() { my ($string, $length, $marker) = @_; my $tempstring = ""; my $afterstring = ""; if ( length($string) > $length && $length > 0 ) { $length -= length($marker); if ($length <= length($marker)) { $marker = ""; $tempstring = substr( $string, 0, $length ); } else { $afterstring = substr( $string, $length, lengt +h($string)); if (length($afterstring) > $length ) { $afters +tring = &breakLine($afterstring,$length+1, $marker);} $tempstring = substr( $string, 0, $length ) . +$marker . " " . $afterstring; } $string = $tempstring; } $string; } $tmpl->param( useremail => &breakLine($user->{email},$length,"-"), ); print $tmpl->output;

As you understand, no nice and clean solution the text www takes more space than aaa or iii.
Is there a way to solve this problem, so if the table is about 150px, i can let perl adjust the text and create a good breakup? i haven't found this in css (yet) as well, second it should be done in perl, since i use the same sort of templating system to create Latex files as well for PDF creation.

In reply to breaking words in a table. by jbrugger

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.