Hi Monks,
I have a html interface of sorts that allows users to add their email address and phone numbers for sms alerts. Additionally, there is a tick box that allows them to turn on and off their alerts. They were susposed to seperate the email addresses, if there were more than 1, with a comma.
i.e. fred@myserver.com,joe@myserver.com
This all worked fine until someone entered 2 addresses on two lines, ie,
fred@myserver.com
joe@myserver.com
Then the whole thing got out of whack. Does anyone have a better way of doing this to ensure the data can't be screwed up?
while (<SERVICES>) { chop; print FH "$_\n"; $temp = $c->param("e$."); if ($temp eq "e$.") { print FH "email 1\n"; } else { print FH "email 0\n"; } $temp = $c->param("el$."); #chomp($temp); $temp =~ s/\n//g; $temp =~ s/\r//g; print FH "$temp\n"; $temp = $c->param("s$."); if ($temp eq "s$.") { print FH "sms 1\n"; } else { print FH "sms 0\n"; } $temp = $c->param("sl$."); $temp =~ s/\n//g; $temp =~ s/\r//g; print FH "$temp\n"; }

In reply to writing a config file from a html form by Anonymous Monk

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.