Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: use CGI Question

by olus (Curate)
on Jul 24, 2008 at 16:00 UTC ( [id://699917]=note: print w/replies, xml ) Need Help??


in reply to use CGI Question

Sample code

use CGI; my $query = new CGI; my $long_text_field = $query->param('long_text_field'); my @BR_paths = split /\n/, $long_text_field;

Replies are listed 'Best First'.
Re^2: use CGI Question
by wfsp (Abbot) on Jul 25, 2008 at 09:05 UTC
    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. :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found