Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Perl Programming Question
#1
I have a web application that allows a user to submit information in "textarea" form fields. The information is written to a MySQL database, and then written out to a text file. The text file is transferred to another system and read into a different type of database.

If the user submitting the form has pressed the enter key in the textarea, or is pasting in from a Word document, there are sometimes html "
" tags in the data. I have been trying to get them out completely, because the text file that is transferred to the other system causes the program on that system to fail if it contains line breaks within a record.

I can get the "
" tags out by doing a perl replace regular expression:
$variable_name =~s/
//g;

but the text file still contains blank lines where it replaced the "
" tags. I'm also doing a replace for \n and \r (the newline characters)--I'm doing that replace before replacing for the "
" tags, if it matters.

Is there a Perl statment I can use to remove blank lines as I read through the variables one by one?


Any help is appreciated.


Doug
Reply
#2
I think I may have figured it out.

Any suggestions are still welcome, though.
Reply
#3
Here are some generic filters I used for form submissions. Strip out HTML & other non-text stuff:

$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s///g;
$value =~ s/<([^>]|\n)*>//g;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)