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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



hielko
Deleted

Feb 1, 2000, 6:59 AM

Post #1 of 3 (1988 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?


hielko
Deleted

Feb 1, 2000, 7:12 AM

Post #2 of 3 (1988 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>

#!/usr/bin/perl

use CGI qw(param);

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


Jasmine
Administrator

Feb 1, 2000, 9:09 AM

Post #3 of 3 (1988 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>;
</pre><HR></BLOCKQUOTE>

$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