Honestly, if you are going to modify a script -- you should learn the programming language in question...
I can spot quite a few problems. For one, when you are inside "quotes" (such as your 'print' statements), you must precede any literal quotes with a backslash.
In other words:
print "This is a "quoted" word";
Will not work. Perl doesn't know the quotes around "quoted" are to be printed literally, so you must do this:
print "This is a \"quoted\" word";
That is one of many, many ways around this problem (Perl is a great language because there is no right or wrong way to accomplish anything).
I won't go any further debugging the code, however; you will need to learn Perl or contract someone (or recruit a guru friend) to help you...
I just realized you're the one asking about escaping in another thread, so I'll give you this quick advice: go through your script line by line, and you will find the bare quotes I mentioned. I am not saying that's the only problem necessarily, as I have not gone through the whole thing.
One more bit of advice: Perl is your friend and, in most cases, will tell you exactly what is wrong with the script.
Run your script with the -c flag, like this:
perl -c filename.pl
The -c flag has Perl check the syntax of your script.
- The way you are handling output is not the best way. Like I said, there is no wrong way, but there are ways to avoid. In this case, printing each line one print statement at a time is very time consuming and (obviously) error-prone.
- Instead of adding two emails to the From: header as you are attempting to do, use a BCC: or CC: header for the secondary destination.
- You are assuming the open() call succeeded. You should always check for success, rather than assuming it will just always work.
Again, learn the language or hire a programmer is my advice.
PS -- what's wrong with using something like Matt Wright's FormMail, instead of modifying this script?