Ionizor has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to get my Perl script to pull newline characters out and put HTML <BR> tags in instead. The idea is that my site's users can post comments that will end up in a text file for SSI inclusion. That part works great but I don't want them to be able to put obscene amounts of blank space in my pages so I want to strip out <BR> tags on otherwise blank lines.
Here's the relevant code:
# $comment is input from the user via web form # Fixes multi-line comments to actually be multi-line $stripvariable = "\n"; $joinvariable = "<BR>"; @commentlines = split(/$stripvariable/, $comment); $comment = join($joinvariable,@commentlines); # This is supposed to eliminate blank lines but it doesn't work # $stripvariable = "<BR>\n<BR>"; # $joinvariable = "<BR>"; # @commentlines = split(/$stripvariable/, $comment); # $comment = join($joinvariable,@commentlines); # I have no idea why this eliminates those funky rectangle # characters from the file but it does. $stripvariable = "<BR>"; $joinvariable = "\n<BR>"; @commentlines = split(/$stripvariable/, $comment); $comment = join($joinvariable,@commentlines);
$comment is then formatted and written to a file (this part also works fine).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: HTML String Parsing
by jeffa (Bishop) on Dec 10, 2001 at 00:14 UTC | |
by Ionizor (Pilgrim) on Dec 10, 2001 at 00:47 UTC | |
by jeffa (Bishop) on Dec 10, 2001 at 02:22 UTC | |
by Ionizor (Pilgrim) on Dec 13, 2001 at 11:33 UTC | |
|
Re: HTML String Parsing
by greywolf (Priest) on Dec 10, 2001 at 00:19 UTC | |
by thraxil (Prior) on Dec 10, 2001 at 01:41 UTC | |
by Ionizor (Pilgrim) on Dec 10, 2001 at 02:10 UTC | |
by Ionizor (Pilgrim) on Dec 10, 2001 at 00:44 UTC |