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;
/\r\n/ produces<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>
and /\n/ gives*one**two**three*
i.e. the carriage returns are still lurking waiting to bite you later on. :-)*one **two **three*
In reply to Re^2: use CGI Question
by wfsp
in thread use CGI Question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |