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

I have come unstuck trying to debug textarea. I have read all the docs I can think of and done all the searches I can think of. So I know that for debugging a POST action with a textarea I really need to include

use CGI qw(-debug);
This means I get prompted for the parameters. However I really need the textarea to be multiline and when I look at the value returned by the textarea it only ever includes the first line. However when I run it a normal server/browser way all the lines are present. So what am I doing wrong when debugging.

Edit: I can produce a simple example. The following script suffices:

use CGI qw(-debug); use strict; use warnings; my $cgi = CGI->new; print $cgi->param('a');
If this is called "a.pl" you can then debug it as
perl -d a.pl
At which point the following happens:
perl -d a.pl Loading DB routines from perl5db.pl version 1.3 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(a.pl:5): my $cgi = CGI->new; + + DB<1> n (offline mode: enter name=value pairs on standard input; press ^D or ^ +Z when done) a='a b v d' main::(a.pl:6): print $cgi->param('a'); + + DB<1> p $cgi->param('a') a b v d + + DB<2> q
Okay I have worked out how to get more than the first line, but the fact that they are separate lines is lost.

Replies are listed 'Best First'.
Re: Debugging textarea
by cmac (Monk) on Dec 05, 2009 at 06:27 UTC
    I've not used the debug features of CGI, and it seems like those are what you're currently having a problem with. If you want to get back to normal operation with an HTML page that has an actual TEXTAREA in it, the trick to getting user-entered line breaks back in the parameter is wrap='hard' in the TEXTAREA tag.

    Try this page which is just one of many you can find by searching for TEXTAREA.

    cmac

      Thanks for the information. I did not know about the wrap attribute but neither "hard" nor "off" made any difference. Anyway the problem was that debugging does not accurately capture what happens on the server.

      Anyway I worked out what was wrong that lead me to try debugging. Because the browser was in windows it was passing a "\r" as well as a "\n".

Re: Debugging textarea
by Anonymous Monk on Dec 05, 2009 at 01:14 UTC
    No one uses that feature, really, no one.