Hello, Monks. This is what I'm using to un-webby-fy data from a web form:
if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; }
However, I'm having trouble when the user doesn't fill out all the fields. Then in the email to the administrator:
open (MESSAGE,"| /usr/lib/sendmail -t"); print MESSAGE "To: $FORM{submitaddress}\n"; print MESSAGE "From: $FORM{name}\n"; print MESSAGE "Reply-To: $FORM{email}\n"; print MESSAGE "Subject: Faculty Bibliography Submission\n\n"; print MESSAGE "The following information was submitted from $FORM{ +name} at $FORM{email}:\n\n"; print MESSAGE "Full Name: $FORM{name}"; print MESSAGE "\n"; print MESSAGE "Publication Name: $FORM{pubname}"; print MESSAGE "\n"; print MESSAGE "Other Authors: $FORM{otherauthors}"; print MESSAGE "\n"; print MESSAGE "Other Editors: $FORM{othereditors}"; print MESSAGE "\n"; print MESSAGE "Main Publication Title: $FORM{pubtitle}"; print MESSAGE "\n"; . . . . close (MESSAGE);
It does not put in the new lines if the user did not fill in a particular field. A new line is only created if there was something entered. My guess is that I need to check for the null (undef??) fields when I un-webby-fy and put a new line "\n" in it instead of leaving it blank. However, my limited perl knowledge keeps me from doing so. Thank you thank you thank you for your help/advice. It would be great if you could e-mail any replies to me as well at elizabeth.dahm@hope.edu

In reply to checking for null variables by edahm

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.