Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: Storing multi-line form data in a flat file?

by Hot Pastrami (Monk)
on Mar 15, 2001 at 02:20 UTC ( [id://64521]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Storing multi-line form data in a flat file?
in thread Storing multi-line form data in a flat file?

If the user types in a backslash than an "n", you'll be fine. If he/she puts in line breaks you simply wish to get rid of, use this:
$text =~ tr/\n\r//;
If you want to replace the line breaks with some other character, place the replacement character between the 2nd and 3rd slashes.

Update: An easier way might be to borrow escape() from the CGI module, which escapes anything non-alphanumeric to it's alias (like "&" becomes "&"):
$text = CGI::escape($text);
When you want to translate it back to it's original form, use CGI::unescape();

Or, if you're trying to make a home-grown database (which is not recommended), try using Berkeley DBM. It'll take care of all that stuff for you, be much faster, and much less bug-prone.

Hot Pastrami

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://64521]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-03-29 06:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found