perl CGI (3)
Visual Basic (1)
New related comments
Number of comments in the last 48 hours
Greating GIF, JPEG or PNG images with perl
Force long strings to break up for better formatting
4 comments. Current rating: (1 votes). Leave comments and/ or rate it.
Question:I have to display text that comes from an external source in a rather narrow column on a web page. I use an HTML table for that and allow it to WRAP. However, sometimes the input text contains very long strings like URLs that cannot be wrapped. The input is out of my control. How can I display such long strings properly?
Answer:You need to parse the string and if there is a substring longer than what you can tolerate, you need to look for special characters like / where you can break it up.
You can use the subroutine posted below and call it with two arguments, the string that needs to be parsed and the estimated maximum word length that you can display.