Re: HTML textarea contents into Perl CGI

2002-07-02 Thread John Brooking

--- David vd Geer Inhuur tbv IPlib
[EMAIL PROTECTED] wrote:
 $data = param('data');
 $data =~ s/\/n/br/g;
  Situation:  I am reading into my script via
  param() a textarea called Job Duties.  When I
print
  out that parameter in perl all of the new lines
are
  ignored and it prints as one long string.  

Here's a slightly more sophisticated algorithm (he
says with great Hubris(tm) ;-) that I wrote about a
month ago. I have a function for either direction, and
they translate double newlines into paragraphs as well
as single ones into line breaks. (Probably appears
identically in most browsers, but seems more
correct.) Also removes any doubt about \n handling,
although it's possible that that doubt is justified
only in my mind. Sorry about the word wraps, those
were inserted by the Yahoo! email editor.

- John

sub NL2HTML {
   $_ = shift;
   s/\x0d\x0a/\x0d/g;# Strip LF out of
CR/LF combinations (Convert DOS - *nix)
   s/\x0d+$//g;  # Strip out any CR at
end, unnecessary (??? WHY NOT WORKING ???)
   s/\x0d{2}|\x0a{2}/\/pp/g; # Replace double CR
or LF with paragraph break /pp
   s/\x0d|\x0a/br/g;   # Replace single CR
or LF with line break br
   return p$_/p;   # Wrap whole thing in
outside p/p
}

sub HTML2NL {
   $_ = shift;
   my $eol = shift || \x0d\x0a;   # Default newline
is CR/LF unless overridden
   s/^p(.*)\/p/$1/; # String out the
outside p.../p
   s/\/pp/$eol$eol/g;   # Replace internal
paragraphs with double newlines
   s/br/$eol/g;   # Replace internal
line breaks with one newline
   return $_;
}


=
Now it's over, I'm dead, and I haven't done anything that I want; or, I'm still 
alive, and there's nothing I want to do. - They Might Be Giants, http://www.tmbg.com

__
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




HTML textarea contents into Perl CGI

2002-06-30 Thread jmpond

Hi,

If this has been answered before please direct me there as I am at a loss as to where 
to look as there is so much info to plow thru.

Situation:  I am reading into my script via param() a textarea called Job Duties.  
When I print out that parameter in perl all of the new lines are ignored and it prints 
as one long string.  

Q: How do I get the perl print statement to recognize the new lines so that the 
printed output looks like the html input screen?

Perhaps the print statement is the wrong thing to use but.

I've been looking at regex's and the split function and have been able to determine 
that there are infact newlines in the data but they are being ignore when I print out 
the data.

Any assistance would be great.

Thanks.

Joe Pond

[EMAIL PROTECTED]



Re: HTML textarea contents into Perl CGI

2002-06-30 Thread Connie Chan

So where do you print out the data ?
In a console ( shell or dosprmpt ) ? or as a html page ?

If that's the first case, it should not be happened unless you do something
to elimate the \n operator If the second case, assum you should know,
HTML will not auto break line even in your souce is. So you better use

print pre$data/pre

or

$data =~ s/\n/BR/g;
print $data




- Original Message -
From: jmpond [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, June 30, 2002 5:31 AM
Subject: HTML textarea contents into Perl CGI


Hi,

If this has been answered before please direct me there as I am at a loss as
to where to look as there is so much info to plow thru.

Situation:  I am reading into my script via param() a textarea called Job
Duties.  When I print out that parameter in perl all of the new lines are
ignored and it prints as one long string.

Q: How do I get the perl print statement to recognize the new lines so that
the printed output looks like the html input screen?

Perhaps the print statement is the wrong thing to use but.

I've been looking at regex's and the split function and have been able to
determine that there are infact newlines in the data but they are being
ignore when I print out the data.

Any assistance would be great.

Thanks.

Joe Pond

[EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]