Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Answer: How do I handle mid-line carriage returns in a flatfile database?

by gryphon (Abbot)
on Dec 02, 2000 at 04:22 UTC ( #44523=categorized answer: print w/replies, xml ) Need Help??

Q&A > regular expressions > How do I handle mid-line carriage returns in a flatfile database? - Answer contributed by gryphon

While this is probably not the best way to go about this, the following has worked for me on many an occation:

use CGI qw(header param); print header; foreach (param) { ($$_ = param($_)) =~ s/\r\n|\n/<BR>/g; }

Note: This won't work with strict, and therefore probably shouldn't be used as is. Something a little safer might be:

(my $some_variable = param('textbox-name')) =~ s/\r\n|\n/<BR>/g;

The key thing is that depending on the user's OS, browser client, or other unknown something, you might end up with your params having just /\n/ or /\r\n/ in them. (Blame Micro$oft. Works for me.) ;) When I'm storing stuff in a flat-file "database," I'll usually store carriage returns as either /<BR>/ or /\\n/ and have Perl, JavaScript, or whatever deal with converting it to something else later.

Shoot me an email if this doesn't help or answer what you're looking for.

Log In?

What's my password?
Create A New User
[ovedpo15]: I need to use FindBin thought. does FindBin finds only modules? or it can find perl script also?
[moritz]: maybe you should start looking at the documentation of FindBin?

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2018-03-17 20:51 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (226 votes). Check out past polls.