Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Re: Parsing user input into CSV table

by lwicks (Friar)
on Apr 14, 2004 at 11:29 UTC ( [id://344994]=note: print w/replies, xml ) Need Help??


in reply to Re: Parsing user input into CSV table
in thread Parsing user input into CSV table

Hmmm....

Really all I want to do is store plain text, the writing of the authors. HTML is just for formating as it will be presented as a web application using IE or a good browser. ;-)

Each "Page" is roughly the length of a page of typed text, if that. The big problem is not the HTML but the commas as in the following example:

This is a example of the problem, this kills it!

This is entered by hand into a textarea box and kills things. I could just write some regex to swap commas for appropriate code but was/am hoping to find a better writtehn/better tested solution. I.e. as I said earlier, I don't want to re-invent the wheel here.

Thanks for the comments,
LANCE

Kia Kaha, Kia Toa, Kia Manawanui!
Be Strong, Be Brave, Be perservering!

Replies are listed 'Best First'.
Re: Re: Re: Parsing user input into CSV table
by William G. Davis (Friar) on Apr 14, 2004 at 11:58 UTC

    Well, if you really want plain text, then Text::CSV will work fine. It appears to handle comma escaping fine. DBD::CSV is probably overkill, as you don't seem to need SQL. I'd still at least consider DBM, though.

Re: Re: Re: Parsing user input into CSV table
by lwicks (Friar) on Apr 14, 2004 at 12:23 UTC
    Further investigation shows that the problem is in fact not commas or html tags etc. Rather newlines.

    So whats the "help the noobie" suggestion for stripping the newline characters from the scaler?

    Lance

    Kia Kaha, Kia Toa, Kia Manawanui!
    Be Strong, Be Brave, Be perservering!

      The "help the noobie" suggestion is to use some already-existing CSV module and let it handle this for you :) Unfortunately, Text::CSV doesn't handle newlines at all. It *could* escape them, but for some reason, it doesn't--it just silently fails when passed newlines.

      Our fellow Monk Tilly has written Text::xSV, which offers a much better interface to CSV than Text::CSV does. It can handle commas and newlines, and provides more file-oriented routines to store the resulting CSV and load it later on: http://search.cpan.org/dist/Text-xSV. Great solution.

      I think I found the answer here 84423
      Opinions?

      Kia Kaha, Kia Toa, Kia Manawanui!
      Be Strong, Be Brave, Be perservering!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (9)
As of 2024-03-28 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found