Re: cgi/Perl ... Removing literal CR's from textarea form submission.

by "Peter Newton" <c-newton(at)ihug.co.nz>

 Date:  Sun, 25 Jun 2000 22:04:32 +1200
 To:  <hwg-techniques(at)hwg.org>
 References:  SOWINSO
  todo: View Thread, Original
Thanks Brian and Darrell,

Aha!! So thats the difference between "tr" and "s" I've so
far always been doing 1 to 1 conversions and puzzling over
what the difference was.

Your solutions worked perfectly

Many Thanks
Peter Newton

-------------------------------------------------
Whats on in New Zealand?
go to http://nzsc.co.nz/

Who is on the net NEAR YOU?
go to http://nzsc.co.nz/
-------------------------------------------------


----- Original Message -----
From: "Brian A. Sayrs" <sayrs(at)southwindsolutions.com>
To: "'Peter Newton'" <c-newton(at)ihug.co.nz>;
<hwg-techniques(at)hwg.org>
Sent: Friday, June 23, 2000 2:51 AM
Subject: RE: cgi/Perl ... Removing literal CR's from
textarea form submission.


> Hey, Peter,
>
> You can't use tr/// (y/// for old timers) because it
translates ONE character to ONE character.  This is a job
for s///
>
> These two lines together will solve your problem:
>
> $value =~ s/\r//g;
> $value =~ s/\n/<BR>/g;
>
> If you're putting together something which may show up on
a web page somewhere, you might want to consider these as
well:
>
> this makes sure there aren't TOO many newlines in a row:
> $value =~ s/\n{3,}/\n\n/gos;
>
> these next two together ensures that the angle braces are
not misunderstood by the browser, and disables HTML at the
same time:
> $value =~ s/</&lt;/g;
> $value =~ s/>/&gt;/g;
>
> HTH,
>
> Brian A. Sayrs
> Owner, Southwind Solutions
>
>
> -----Original Message-----
> From: Peter Newton [SMTP:c-newton(at)ihug.co.nz]
> Sent: Wednesday, June 21, 2000 6:40 PM
> To: hwg-techniques(at)hwg.org
> Subject: cgi/Perl ... Removing literal CR's from textarea
form submission.
>
> Hello all,
>
> Thanks for all the good tips on flash4 detection, After
all
> that I went to download the program and it crashes with
that
> "This program has performed an illegal operation" error
> message. No one seems to want to assist so I'll have to
> shelve it for the moment.
>
> My problem now is that I'm receiving forms from my website
> which contains  textarea inputs, however if anyone puts in
a
> literal CR in this field it mucks up my perl program which
> filters the forms. One solution is to convert any literal
> CR's into BR tags but I'm having trouble trying to detect
a
> literal CR. using  tr/ / / or s/ / /g.
> Can anyone help.?
>
> Many Thanks
> Peter Newton
>
>
>
> -------------------------------------------------
> Whats on in New Zealand?
> go to http://nzsc.co.nz/
>
> Who is on the net NEAR YOU?
> go to http://nzsc.co.nz/
> -------------------------------------------------
>
>
>
>
>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA