in reply to Re: use CGI Question
in thread use CGI Question

Minor nit.

A textarea comes in with carriage return/line feed pairs.

/\n/ will leave the carriage returns behind (on windows and nix). It may be better to use /\r\n/ instead.

#!c:/perl/bin/perl.exe use strict; use warnings; use CGI; my $q = CGI->new; #my @lines = split /\n/, $q->param(q{txt_area}); my @lines = split /\r\n/, $q->param(q{txt_area}); print $q->header; print qq{*$_*} for @lines;
<html> <head> <title>textarea test</title> </head> <body> <form name = "txt_area_form" action = "/z/bin/test_form.cgi"> <textarea name = "txt_area" rows = "3" cols = "10"></textarea> <input type = "submit"> </form> </body> </html>
/\r\n/ produces
*one**two**three*
and /\n/ gives
*one **two **three*
i.e. the carriage returns are still lurking waiting to bite you later on. :-)