Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Stings - textareas in Perl...

Reply
Thread Tools

Stings - textareas in Perl...

 
 
joesplink
Guest
Posts: n/a
 
      03-28-2005
1. Is there a free script for putting up a textarea with controls for
fort/size/color...etc. for the entered text.. ????

2. A TEXTAREA control can return a string with newlines (?) in it,
but, when I print the string the newlines are supressed and everything
prints on a single line.... what is going on? .... how do I get a
string from a textarea and print it without supressing the
newlines....and... how can I save it to a file...as a single line....so
that it will read as one line.. ??????

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      03-28-2005
"joesplink" <(E-Mail Removed)> wrote in news:1111970860.166658.282720
@l41g2000cwc.googlegroups.com:

> Subject: Stings - textareas in Perl...


There are no textareas in Perl.

> 1. Is there a free script for putting up a textarea with controls for
> fort/size/color...etc. for the entered text.. ????


How textareas are rendered is a user agent feature. I am guessing this
question would be more appropriate in a Javascript/HTML/CSS group.

> 2. A TEXTAREA control can return a string with newlines (?) in it,
> but, when I print the string the newlines are supressed and everything
> prints on a single line.... what is going on? .... how do I get a
> string from a textarea and print it without supressing the
> newlines....and... how can I save it to a file...as a single line....so
> that it will read as one line.. ??????


I don't know if there is a Perl question in there. This is more a question
about CGI, HTML, and user agent interaction.

Sinan.
 
Reply With Quote
 
 
 
 
joesplink
Guest
Posts: n/a
 
      03-28-2005
I'll try to be less vague. My PERL script gets input from a TEXTAREA
that contains newlines. I can replace /\n/#/g and print the result and
see the #'s where I expect them. However, if I print the string (not
replacing the \n's) by including it in an HTML document I send to the
browser, it prints as a single line. How can I get it to print showing
the newlines as originally entered in the TEXTAREA???

 
Reply With Quote
 
joesplink
Guest
Posts: n/a
 
      03-28-2005
Check... see that I must insert <br>s in the HTML.

 
Reply With Quote
 
nobull@mail.com
Guest
Posts: n/a
 
      03-28-2005
Without any context joesplink wrote:

> I'll try to be less vague.


Please give context (quoted material) in your follow-up posts.

Also try to partition your problem - work out what is the question that
you are asking, and what is just the context in which the question
arrose.

> My PERL script gets input from a TEXTAREA
> that contains newlines. I can replace /\n/#/g and print the result

and
> see the #'s where I expect them. However, if I print the string (not
> replacing the \n's) by including it in an HTML document I send to the
> browser, it prints as a single line. How can I get it to print

showing
> the newlines as originally entered in the TEXTAREA???


It would appear that the question you are asking is how to represent a
newline in HTML.

This has nothing to do with Perl - it is a pure HTML question.

The representation of newline in HTML is <br>.

Note also that the '<' and '&' must also be represented specially in
HTML so convert your string with escapeHTML before you s/\n/<br>/.

 
Reply With Quote
 
Scott Bryce
Guest
Posts: n/a
 
      03-28-2005
joesplink wrote:

> I'll try to be less vague. My PERL script gets input from a TEXTAREA
> that contains newlines. I can replace /\n/#/g and print the result and
> see the #'s where I expect them. However, if I print the string (not
> replacing the \n's) by including it in an HTML document I send to the
> browser, it prints as a single line. How can I get it to print showing
> the newlines as originally entered in the TEXTAREA???


This is an HTML issue, not a Perl issue.

s(\n)(<br />)g;

might be a Perl way to solve your HTML problem.
 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      03-28-2005
"joesplink" <(E-Mail Removed)> wrote in news:1111982945.105772.52280
@f14g2000cwb.googlegroups.com:

> Check... see that I must insert <br>s in the HTML.


It sounds like you are talking to yourself.

Please quote an appropriate amount of context when replying.

Please note that whatever your problem was, it had nothing to do with
Perl.

Sinan.
 
Reply With Quote
 
joesplink
Guest
Posts: n/a
 
      03-28-2005
Hmmmm, curiouser and curiouser ... I have tried s/\n/<br>/g.... and the
string prints OK as HTML..... however, I save the string to disc with
the <br>s.... and convert the <br>s back to \n's when I want to put it
back in the TEXTAREA for further editing.... and my stings are
growing....

I note that if I type A in the TEXTAREA, the length of the string
returned is 1, whereas if I type A<enter>, i.e, 2 keystrokes, A and
<enter>, the length of the string returned is 3..... not 2..... so the
TEXTAREA is returning more than the \n for an <enter>.....and my PERL
is not yet up to telling me what the other character is ...... what is
it ????? linefeed ? \l ?????

 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      03-28-2005


joesplink wrote:

> Hmmmm, curiouser and curiouser ... I have tried s/\n/<br>/g.... and the
> string prints OK as HTML..... however, I save the string to disc with
> the <br>s.... and convert the <br>s back to \n's when I want to put it
> back in the TEXTAREA for further editing.... and my stings are
> growing....
>
> I note that if I type A in the TEXTAREA, the length of the string
> returned is 1, whereas if I type A<enter>, i.e, 2 keystrokes, A and
> <enter>, the length of the string returned is 3..... not 2..... so the
> TEXTAREA is returning more than the \n for an <enter>


Carriage return.

HTML form text areas delimit lines with CR-LF.

Why it should grow when you change the LF to <br> and back is not
obvious to me. How are you writing it out to disk and reading it back?

Better not to anyhow. If you want to be able to edit the text then
store it as entered. Transform it when you come to display it.

And don't forget the escapeHTML.

 
Reply With Quote
 
joesplink
Guest
Posts: n/a
 
      03-28-2005
Yes, TEXTAREA is returning cr-lf for new lines... so, I thought my
problems were over.... but nooooo....

if, in my Perl routine I code

my $Field = "A\r\n\B";

and then generate a form

print ........."<TEXTAREA.......>$Field</TEXTAREA>

and then click on Done without editing, the TEXTAREA will return
"A\r\nB"

However, if I code
my $Field = "A\r\n\B\r\n";

I still only get back "A\r\nB", i.e. I"ve lost my trailing cr-lf.


On the other hand....... if I generate the form with

print <TEXTAREA.......>$Field
</TEXTAREA>

then a cr-lf will be appended to the value of $Field......


As a geek I know likes to say ..... it's very cornfusing......

Oy Vey ............

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: They're starting up with the STINGS again zvnteq7 Computer Support 1 05-10-2009 12:36 AM
Re: They're starting up with the STINGS again Pennywise@DerryMaine.Gov Computer Support 0 05-09-2009 07:54 AM
perl: adding lines and replacing stings erobinson32 Perl Misc 14 03-23-2007 03:32 PM
Searching Stings with Arrays? Phil Cooperking Ruby 11 12-25-2006 10:06 PM
Reading information from TextAreas MacEgan Java 2 12-17-2005 11:34 PM



Advertisments