Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

syntax error

by keiththirgood (Initiate)
on May 21, 2017 at 15:39 UTC ( [id://1190804]=perlquestion: print w/replies, xml ) Need Help??

keiththirgood has asked for the wisdom of the Perl Monks concerning the following question:

I am new to all coding and I have no idea what is wrong here. I have a simple form I'm trying to send cleaned up results from to an email address. This is the error message I received:

syntax error at feedback.cgi line 33, near "print MESSAGE "From"

syntax error at feedback.cgi line 35, near "n\"

syntax error at feedback.cgi line 79, near "}"

Execution of feedback.cgi aborted due to compilation errors.

This is the code near each of those lines:

32 print MESSAGE "To: keith\@wilsonstreetstudio.ca\n”; # Don't forget to escape this @ symbol!

33 print MESSAGE "From: " . $FORM{name} . ", reader\n";

34 print MESSAGE "Reply-to: " . $FORM{email} . "(" . $FORM{name} . ")\n";

35 print MESSAGE "Subject: Feedback from $FORM{name} \n\n";

36 print MESSAGE "$FORM{name} wrote:\n\n";

76 EndHTML

77

78 exit(0);

79 }

Replies are listed 'Best First'.
Re: syntax error
by Corion (Patriarch) on May 21, 2017 at 15:46 UTC
    print MESSAGE "To: keith\@wilsonstreetstudio.ca\n”; # Don't forget to +escape this @ symbol!

    The last double quote on line 32 is not a real double quote that Perl recognizes but something your text editor made up. Change the last thing to a proper double quote.

    Also, note that your feedback form is prone to be abused as a spam sender. If somebody maliciously sends a newline in the email address field, they can add additional Cc headers to your email, making your mail host send out spam to them. Please consider not printing into sendmail and use MIME::Lite or some other module to send mail.

    Also, you might be interested in using the TFMail script to send mail.

Re: syntax error
by ww (Archbishop) on May 21, 2017 at 17:52 UTC

    Re the doublequote: that appears to be a typographic dblquote -- the kind that M$ Word sticks into one of its docs when thus configured. If you, OP, are using Word to write code, abandon all hope ... or switch to one of M$ text editors... or, better, pick one that does what you say it should; not what the maker/seller wants it to do.

    Which one: depends on what you try and like. Editor preference tends to be right up there with religion when folks disagree. But -- at the (very high) risk of incurring the wrath of some folk (for my obscene failure to mention their favorite), here are just a few of the many, possibly useful (mostly free) choices:

    • Notepad++ (windows)
    • editpadlite ('doze)
    • Atom (non-denominational as to OS)
    • Vi/Vim (*nix including apple's variant/windows)
    • emacs (ditto)
    • Light Table (GGIFY)
    • Bluefish (definitely Linux, not sure about other OSen)
    • gedit (likewise)
      ... and my own (widely dismissed) choice:
    • NoteTab (windows; pro version is not free but if you try the lite and like it, well worth the upgrade price -- < 20 USD)

    This -- because I'm out of ambition -- is only a small sample what what you may want.

    Now, some observations that may help you avoid having to repeat your statement that you "have no idea what is wrong here."

    Your perl toolkit offers a variety of ways to find out what those messages mean. The one that leaps to mind, as simple and helpful (albeit not perfect) is use diagnostics; or even use diagnostics -verbose;. The latter will -- as the argument suggests -- offer a more extensive explanation of that's going wrong and/or how to fix it.

    Heed Corion's answer -- fixing the doublequote may solve most of your problems and his warning against the deprecated and dangerous sendmail is gospel.

    But.... as gently as I know how, you need to understand that listing single lines of code doesn't give us much to go on to help you. You reference $FORM{name} repeatedly, but don't show us the form's code. Please read On asking for help and How do I post a question effectively? (among other site-specific documents).

    Also note that what seems likely to be an attempt to produce a newline at LN 35 with the slash trailing the 'n' instead of preceding it. Fixing the typographic quote isn't going to fix that.

    Welcome. HTH.

    ++$anecdote ne $data

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1190804]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-19 09:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found