http://www.perlmonks.org?node_id=1187010


in reply to Re: Form Stopped working
in thread Form Stopped working

Very nice catch!! Thank you soon much!

Replies are listed 'Best First'.
Re^3: Form Stopped working
by poj (Abbot) on Apr 04, 2017 at 16:16 UTC

    You might consider making the script more consistent with a variable

    my $emailCC = 'Any Person <anyperson@anywhere.com,nobody@nobody.com,so +mebodyelse@icloud.com>'; print MAIL "To: $emailTo\n"; print MAIL "Cc: $emailCC\n"; . .
    poj
      For situations where you have a stream of lines, a here-doc can significantly improve readability. As well, a two-argument open without a check is considered bad practice. Combining all this with a lexical filehandle and poj's suggestion, I might write your script as:
      my $emailTo = 'Customer Service <customerservice@df-foods.com>'; my $emailCC = 'Frank Simmons <fsimmons@oregonpotato.com,susan@ftiegs.c +om,jenbrink@icloud.com>'; my $emailFrom = FilterCChars($FTGEmail); open(my $mail,'|-', $mailProg) or die "Problem accessing $mailProg: $! +"; print $mail <<EOT; To: $emailTo Cc: $emailCC From: $emailFrom Subject: $emailSubject Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit $emailBody EOT close $mail; # Redirect user to success page print "Location: /thankyou.html\n\n"; exit;
      Note how much cleaner that looks without all the newlines and print commands.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.