0

I'm iterating through a hash and printing the output to a HTML file in perl.

Currently I'm able to print to the HTML file but the text characters are getting printed out of the table row for a particular field called - FILES.

For certain values there are multiple file paths for the field "FILES", hence data is getting printed out of the table.

In HTML how can I limit the content or the table data to be printed within the Row.

I tried using the wrap but of no use:

<td wrap>$$val{Files}</td> 

and

<td nowrap>$$val{Files}</td> 

I want the extended files or path to get fit in to the particular cell without flowing out of the row.

Below is my piece of code:

foreach $prg (keys %work) { print FH "<font color = #000000> <font size = 4> <u><center><br/>Design: <b>$prg</b></center></u></font>\n"; foreach $jir (keys %{$work{$prg}}) { print FH "<p><font color = #000000><b>DESIGN ID:$jir</b></font></p> "; @myarr = @{$work{$prg}{$jir}}; foreach $val (@myarr) { print FH "<body><table border=1 width=100% style='table-layout:fixed'></body>\n"; print FH "<col width=6%> <col width=5%><col width=10%><col width=15%><col width=10%><col width=50%>"; print FH "<tr bgcolor=##4169E1><th><font color = #FFF5EE>Design_ID</th><th><font color = #FFF5EE>Submitter</th><th><font color = #FFF5EE>Reviewer</th><th><font color = #FFF5EE>Description</th><th><font color = #FFF5EE>Date</th><th><font color = #FFF5EE>Files</th></tr>\n"; print FH "<tr bgcolor=#FFF8C6 border=1><td>$$val{design}</td><td>$$val{Initial}</td><td>$$val{Reviewer}</td><td bgcolor=#FFF8C6>$$val{Description}</td><td>$$val{time}</td><td>$$val{Files}</td></tr>\n"; print FH "</table>\n"; } } } 
4
  • Try this stackoverflow.com/questions/28642049/… word-break: break-all; word-wrap:break-word; Commented Aug 26, 2016 at 11:01
  • As well as the top answer in this Commented Aug 26, 2016 at 11:04
  • Thank you @AbhiNickz & Drav Sloan for your inputs Commented Aug 26, 2016 at 11:41
  • Have you heard about XSS attacks? Your code does not seem to protect against malicious data injected in %work. Commented Aug 30, 2016 at 11:03

1 Answer 1

0

welcome to Stack Overflow.

You can possibly solve this by using CSS. Which can either be used by using an external stylesheet or inline style tag.

For example (as seen in CSS text-overflow in a table cell?)

td { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } 

Though looking at your code, I think you might refactor or cleanup your HTML. I'm not experienced with Perl but guessing from other languages.

The body tag should only be used once per HTML file/output. The font and center tags are deprecated in favor of CSS. I thought col was not an element at all, but seems it had just been deprecated for a long time. Having such errors in your HTML might lead to unexpected rendering issues as well.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks much for your suggestion , will try from my end.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.