View Full Version : inserting <br>
windowcleaner
10-11-2005, 08:14 PM
I've got a string named $text in my script which contains some retrieved data.
Now I want to insert a <br> tag at each 60th postion.. so on the 60th, 120th..and so on.. I havent got a clue what code to do this..
FishMonger
10-11-2005, 11:24 PM
It's not a good idea to break the lines like that. Have you looked at the modules that Jeff suggested in your prior question?
Text::Format
http://search.cpan.org/~gabor/Text-Format0.52/lib/Text/Format.pm
Text::Wrap
http://search.cpan.org/~muir/Text-Tabs+Wrap-2005.0824/lib/Text/Wrap.pm
windowcleaner
10-12-2005, 06:39 AM
hmm yes fishmonger, but i cant get them to work.
For example if I try the text::wrap module like this:
---------------------------------
#!/usr/bin/perl -w
use CGI;
use Text::Wrap;
print "Content-type: text/html\n\n";
@text="1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111";
$Text::Wrap::columns = 60;
#print wrap('', '', @text);
print wrap("\t","",@text);
----------------------------------
it inserts tabs at certain points. I looked at the cpan site about this, but can't find a solution. so I thought, if I place <br> tags at each 60th position, I would get the same effect..
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.