[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

Removing new lines

Hi,

My script process a form.  I wish to store the $message value in a text file.  Simple.  But it needs to store the $message on 1 line only.

At the moment, if the visitor presses the <ENTER> key a few times, then when they submit it stores on more than 1 line.

Any ideas?  Thanks in advance,

Graeme Sandwell

Email - graeme@sandwell98.freeserve.co.uk
0
graemesandwell
Asked:
graemesandwell
1 Solution
 
graemesandwellAuthor Commented:
Edited text of question.
0
 
thoellriCommented:
Do a:

  $message =~ s/[\r\n]/ /g;

before you write to the file. This will delete all carriage-returns/line-feeds and replace them by a space.

hope this helps
  Tobias
0
 
helverCommented:
You probably want:

$message =~ s/[\r\n]+/ /g;
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
ozoCommented:
Or even:

$message =~ s/\s+/ /g;
0
 
mwimerCommented:
Hate helping you brits[:), but:

print FILEHAND split([\n\r], $message);

one line?  this is perl...
0
 
graemesandwellAuthor Commented:
It didn't work!
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now