inblosam has asked for the wisdom of the Perl Monks concerning the following question:

I have a form that I am submitting to a database, then editing again. The textarea does not maintain the line breaks! Of course this is highly annoying. I have tried to substitute \r\n with various things, but nothing seems to work. Any ideas? I am also wondering if there is a way to display what the end of line character is, even some little perl code. Sometimes I wonder what all the different line endings are because of various apps (I am on a mac, so some use mac, some unix, others input may have windows, etc.). Is there some way to see what line endings are? The preview on this does it fine...what am I doing wrong!!! THANKS!


Michael Jensen
michael at inshift.com
http://www.inshift.com
  • Comment on line breaks in textarea; end of line characters?

Replies are listed 'Best First'.
Re: line breaks in textarea; end of line characters?
by idsfa (Vicar) on Oct 23, 2003 at 04:26 UTC

    $/ and $\ seem to be what you are looking for. Look for $INPUT_RECORD_SEPARATOR and $OUTPUT_RECORD_SEPARATOR in perlvar.


    Remember, when you stare long into the abyss, you could have been home eating ice cream.
Re: line breaks in textarea; end of line characters?
by inblosam (Monk) on Oct 22, 2003 at 23:59 UTC
    Some more info:
    The reason I wonder about the various apps is when copying text from them and then pasting it into a textarea.

    Also, I am using DBI and CGI::ReadParse for capturing the variables and updating the record in the database.

    Anything would help, I just feel stuck!


    Michael Jensen
    michael at inshift.com
    http://www.inshift.com
Re: line breaks in textarea; end of line characters?
by inblosam (Monk) on Oct 23, 2003 at 00:12 UTC
    Okay, false alarm. I figured out how to preserve the line endings.

    BUT I still am interested in info about line endings and how to look at what is at the end of a line of text.

    What is cJ, cM, cJcM and their relationship to \r, \n, etc. Are there more?



    Michael Jensen
    michael at inshift.com
    http://www.inshift.com
      cJ or ^J (or ctrl-J) are some applications' means of representing the newline character (NL, "\n", ascii 0x0A, etc). Likewise cM or ^M (or ctrl-M) for the carriage return character (CR, "\r", ascii 0x0D).

      ------------
      :Wq
      Not an editor command: Wq

      "\cJ" is CTRL-J ("Control J"), which is what ASCII uses for "\n". "\cM" is CTRL-M, which is what ASCII uses for "\r". (Old Macs claim to be ASCII but get these two associations backward.)

      You might want to read a recent related rant of mine: Re^4: Line Feeds (rumor control)

                      - tye