Gossamer Forum
Home : Products : Links 2.0 : Customization :

Help with LINE BREAKS in ADD.CGI

Quote Reply
Help with LINE BREAKS in ADD.CGI
 

Is there a better way to do this:


Code:


if ($in{$db_cols[$$db_description]}) { #Here
$in{$db_cols[$db_description]} =~ s/\n\n/<br><br>/g;
$in{$db_cols[$db_description]} =~ s/\n/<br>/g;
}


What I am trying to allow, is someone to enter text into the desc ( for lit.org , it will be a poetry/fiction etc archive ). The above code works, but its buggy. Any help would be GREATLY appreciated ..

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!



Quote Reply
Re: Help with LINE BREAKS in ADD.CGI In reply to
$in{$db_cols[$db_description]} =~ s/\n/<br>/g;

that one line would do it all...

how is it buggy?
Quote Reply
Re: Help with LINE BREAKS in ADD.CGI In reply to
see what you are currently doing is sorta silly.. you are finding places with 2 newlines.. so it changes it.. and then you find all the ones with one newline.. then it changes that.. you don't even need the

if ($in{$db_cols[$$db_description]}) {

part.. plus that is not even the right code.. it should be..

if ($in{$db_cols[$db_description]}) {

if you use the one liner above.. it will replace all \n\n... with <br><br> because it's still \n...

if there is no description it will just skip it! Smile

jerry
Quote Reply
Re: Help with LINE BREAKS in ADD.CGI In reply to
You guys must be reading my mind....

I was just thinking about this....

But Widgetz, where do I put this one liner of yours to get the wanted result??

Jeroen

------------------
Free 4U2: a searchable directory of free stuff
http://www.free4u2.com

When something does not function properly, hit it hard.....
.....When it breaks it had to be replaced anyway.


Quote Reply
Re: Help with LINE BREAKS in ADD.CGI In reply to
hmm...

above

Code:
$status = &validate_record(%in);
Quote Reply
Re: Help with LINE BREAKS in ADD.CGI In reply to
Thanx Widgetz, that did the trick.

The 2 lines I had worked, but like you said, was adding to many br's . I'm no perl guru, but thats what I kinda figured Wink

I figured out what I thought was " buggy " ... When someone submits a text file, it was sorta chopping it up mid sentance, and after some digging, I found what was happening is that I ( they ) weren't letting the text box do the wrapping and were hitting enter some of the time.. I'll just have to post a little "How to post a story" link on the ADD page.. Thanx again for the hookup.

------------------
The Crowe crowe@charter.net
www.lit.org Links Engine for Writing on the net!