Forum Moderators: open

Message Too Old, No Replies

TEXTAREA line breaks

Passing data to Perl script

         

The Cornishman

11:01 am on Feb 21, 2007 (gmt 0)

10+ Year Member



Hi,

I have written a Perl script which formats the contents of an HTML form into a new page to be displayed back to the user. This works very well except for the one and only TEXTAREA box. Here, I find that any carriage-returns entered by the user in the form are ignored when I use the Perl 'print' command to write the info to the screen...

So for example:-

Hello there.
This is a new line.

Is formatted as Hello there. This is a new line.

I have scoured the internet for a solution to this problem - there seem to be a few PHP related suggestion, but nothing I've been able to adapt for my particular situation.

Does anyone have any ideas - this must be possible surely?

adb64

11:06 am on Feb 21, 2007 (gmt 0)

10+ Year Member



All \n in formdata from the textarea must be changed into <br> to get a newline in the HTML.

The Cornishman

11:55 am on Feb 21, 2007 (gmt 0)

10+ Year Member



OK, thank you I will try this.

Have already tried similar things without success - I can't decide whether this is partly because I'm running on a local 'test' web server rather than my live Linux server - perhaps I should just copy the code to live and test it! I would rather not do that yet if possible though.

Thanks for the advice anyway.

kaled

12:44 pm on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Alternatively, display the content of the <TextArea> within a (styled) <pre> block.

Kaled.

The Cornishman

2:57 pm on Feb 21, 2007 (gmt 0)

10+ Year Member



OK, I will try this too. I've already had a go at this once, but failed to get the desired effect ... Is it just a matter of generating <PRE> and </PRE> tags either side of a simple 'print' of the TEXTAREA data in the Perl script, i.e. something like -

my $textinfo = $input->param("textinfo");

print "<PRE>";
print "$textinfo";
print "</PRE>";

.. or is that far too simplistic?

Incidentally, in case you are wondering why I don't just try it, I am not at my own PC at the moment...

Thanks again for your help and advice.