PDA

Click to See Complete Forum and Search --> : CGI/Perl -> Replace <CR> with \r\n


wpearsall
Jan 5th, 2003, 02:57 PM
hey ya,

OK, how do i replace <CR> with \r\n in CGI?

I thought that



$Description = "This is <CR> LINE ONE <CR>LINE 2<CR> LINE THREE";

$Description =~ s/<CR>/\r\n/g;


should do it? (Seams like not though)

NE 1?

[oh btw this code:]


$input{'a_text'} = "Line\r\n1\r\n2\r\n3";
$input{'a_text'} =~ s/\r\n/<CR>/g;

makes it output to:
Line<CR>1<CR>2<CR>3

JoshT
Jan 8th, 2003, 10:25 AM
It works fine for me. Are you writing to a file? Perhaps Perl is translating the \r\n to the line breaker of your OS?