Solved

using a textarea

Posted on 1998-10-12
5
180 Views
Last Modified: 2010-03-05
Ok, this is really easy, but for some reason its just not working for me.  I have a textbox and i want to take any enters (newlines) out of it.  I want to store it in one line, not have multiple lines.  I tried putting the textarea into an variable ($texarea) and then doing $texarea =~ s/\n//g; but this didn't work...Is this wrong?  Its really bugging me, any suggestions or answers would be greatly appreaciated, Thanks.
0
Comment
Question by:idadan
5 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1205278
carriage returns are \r
0
 

Author Comment

by:idadan
ID: 1205279
newlines, i mean, sorry..
0
 

Author Comment

by:idadan
ID: 1205280
Edited text of question
0
 
LVL 2

Expert Comment

by:shchuka
ID: 1205281
Basically, you should try doing both:
    $textarea ~= s/\r|\n//g;
Maybe then it will help.  Also, how is your textarea defined?
the format may be something like
    <textarea name=mytext cols=40 rows=10 wordwrap=HARD|SOFT|NONE>
check what you have for wordwrap.  If you have anything but NONE, it
will automatically wrap your text
0
 

Accepted Solution

by:
mazares earned 50 total points
ID: 1205282
Do it like this:

$texarea =~ s/\r\n/~/g;

I use ~ as a code for CRLFs -- any other character you know you're not going to use for any other purpose will work. If you need later to retrieve the record and display it in a textarea,
convert it back like this:

$texarea =~ s/~/<p>/g;


0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
crawling gofundme 4 126
Perl string replace for refred url 9 62
Perl DBI Transactions Using Custom Module 7 47
ppm conversion to curl on a module install 8 82
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question