CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Replace linebreak

 



patrik
stranger

Jul 7, 2001, 4:12 AM

Post #1 of 6 (790 views)
Replace linebreak Can't Post

Ok here goes.
I need to replace the \n linebreak thing from a form textarea with a <BR> tag.
I got this
$xline =~ s/\n/<BR>/g;
But it still goes to a new line before the BR tag!!!
I need the string on ONE line, not a new line before
every BR tag.

Please help me out here.
Thanx in advance Patrik

Excuse the bad english
Im from Sweden ;)


Pro_4
User

Jul 7, 2001, 7:29 AM

Post #2 of 6 (787 views)
Re: Replace linebreak [In reply to] Can't Post

i use that same thing for my message board and it works fine for me.... maybe try substituting \r , isnt that the return key?

Anyways i hope that helps

@letters = ('A'..'Z', 'a'..'z', '1'..'5', '_');
@i = ( '15', '43', '40');
print @letters [ @i, -1, 55];


mhx
Enthusiast / Moderator

Jul 7, 2001, 8:20 AM

Post #3 of 6 (785 views)
Re: Replace linebreak [In reply to] Can't Post

Hi patrik,

Pro_4 is somehow right. There's an optional \r symbol in front of the \n (which itself is AFAIK always present). Try this pattern to get rid of the linebreaks in (hopefully) all cases:

Code
$xline =~ s/\r?\n/<BR>/g;

Hope this helps.

-- Marcus



patrik
stranger

Jul 7, 2001, 5:17 PM

Post #4 of 6 (777 views)
Re: Replace linebreak [In reply to] Can't Post

Tnx alot :)
Just what I wanted.

Regards Patrik

Excuse the bad english
Im from Sweden ;)


Pro_4
User

Jul 7, 2001, 8:43 PM

Post #5 of 6 (774 views)
Re: Replace linebreak [In reply to] Can't Post

quote:
Pro_4 is somehow right.

What are you trying to imply?? lol yes i was amazed that i was somehow right too.


@letters = ('A'..'Z', 'a'..'z', '1'..'5', '_');
@i = ( '15', '43', '40');
print @letters [ @i, -1, 55];


mhx
Enthusiast / Moderator

Jul 8, 2001, 12:13 AM

Post #6 of 6 (771 views)
Re: Replace linebreak [In reply to] Can't Post

Hi Pro_4,

sorry, I didn't want to imply anything. I just looked up 'somehow' in some good dictionary and found that its meaning was not what I intended to say. What I wrote must have sounded like 'O, I can't believe it, but Pro_4 is right', and believe me, that wasn't my intention. What I was trying to say was something like 'Pro_4 is on the right way, but his solution is only part of the whole'. I should have written 'particularly' instead of 'somehow', but somehow sounded somehow good to me as I was writing ;-)

Sorry again...

-- Marcus


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives