Gossamer Forum
Home : General : Perl Programming :

How to print in one line?

Quote Reply
How to print in one line?
I have no experience in programming but i want to modify something in a cgi program.

I have a textarea for users to enter their description. After they have submitted the form, the program use the following lines to print the data to the database file

$newline = join ("\|",0,0,$fields{'description'},$fields{'pass'},$new_id);
$newline .= "\n";

But the data file is totally messed up when the user press enter in the description fields.

How to modify it so that each record can be printed on only one line.
Quote Reply
Re: How to print in one line? In reply to
The following means newline, so try deleting that.

Code:
\n

Quote Reply
Re: How to print in one line? In reply to
The new line "\n" is used for the next record to be entered. I want one record in one line but not all records in the same line.
How can i do that?
Quote Reply
Re: How to print in one line? In reply to
You could just strip out all enters (\n) from the description that the user entered.

$fields{'description'} =~ s/\n//g;

But, that will remove the newlines permanantly from the description (like when you print that description somewhere). If you want to be able to remove it for storage in your file, but still retain it for printing output, you'll have to get a little creative Smile

--Mark


------------------
You can reach my by ICQ at UID# 8602162