freelanceprogrammers.org Forum Index » Perl

line brakes


View user's profile Post To page top
Ramesh_thiru Posted: Sun Oct 24, 1999 10:30 am


Joined: 24 Oct 1999

Posts: 2
line brakes
I have a text area , when submitting the data I want to remove all the line
brakes who can I do that in perl ? <br><br>How Can I replace line bakes (
chr(10) ) with &lt;br&gt; ?
Reply with quote
Send private message
View user's profile Post To page top
Shetan11 Posted: Mon Oct 25, 1999 2:18 am


Joined: 07 Jul 1999

Posts: 4
line brakes
To change line breaks to the string &lt;br&gt; you could try<br><br>|
s/
/&lt;br&gt;/g;<br><br>or a variant on it. Is this what you were looking
for?
Reply with quote
Send private message
View user's profile Post To page top
ccoolkidd Posted: Thu Oct 28, 1999 3:22 am


Joined: 28 Oct 1999

Posts: 1
line brakes
Well, there`s two ways to replace the line
breaks:<br><br>First, you could just replace them with "tr", like
so:<br><br>$string =~ tr/
/&lt;br&gt;/;<br><br>Or, you could turn
it into a list and then print each item with a
&lt;br&gt; after it, like this:<br><br>@lines = split(/
/,
$string);<br>foreach $line (@lines) {<br> print
"$line&lt;br&gt;
";<br>}<br><br>Either way would work. At least they did for
me!<br><br>P.S. I know there`s a trailing &lt;br&gt; at the end
if you use the second method....if you need help
getting rid of that just holler!
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help