CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
problems with the texarea html tag



Feb 1, 2000, 6:59 AM

Post #1 of 3 (5112 views)
problems with the texarea html tag Can't Post

I have a little problem:

When I have a form with the <textarea> tag I enter some tekst in it, it works ok - the script writes the entered texts to a txt file but when I use another form with again the textarea tag it won't display the whole tekst only the part before the first enter.

How is this possible, and more inportant what can I do about it?


Feb 1, 2000, 7:12 AM

Post #2 of 3 (5112 views)
Re: problems with the texarea html tag [In reply to] Can't Post

the code below is a script which demonstrates the problem:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


use CGI qw(param);

open (FILE, ">temp.txt");
print FILE param("textfield");
print "Content-type: text/html\n\n";
print '<form method="post" action="">';
print '<textarea name="textfield">';
open (FILE, "temp.txt");
$txt = <FILE>;
print $txt;
print '</textarea><input type="submit" name="Submit" value="Submit"></form>';


Feb 1, 2000, 9:09 AM

Post #3 of 3 (5112 views)
Re: problems with the texarea html tag [In reply to] Can't Post

That's because the input record delimeter (held in $/) is a newline by default.

Perl, by default, considers each line in a file a record. So to slurp the entire contents of the file into a scalar (that is, to define the record as the complete multiline file), you'll first need to clear the default record delimeter.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

open (FILE, "temp.txt");
undef $/;
$txt = <FILE>;

$txt will now hold the entire contents of <FILE>


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives