Actually, given that the email displays them as the OP desires, but that he wants the results to show up on the web page in the same manner, <pre></pre> tags around the variable will in fact take care of the issue, without having to worry about looking at the parameter in question as a scalar or array.

Test results, result display section, CGI based on OP's provided code
TestHTML codeDisplayed
Sample results, original code
<html> <body> Names here: duh<br />Names here: joe bob mary<br /> </body> </html>
Names here: duh
Names here: joe bob mary
Sample results, <pre></pre> tags around $name
<html> <body> <pre> Names here: duh<br />Names here: joe bob mary<br /> </pre> </body> </html>
Names here:	duh
Names here: joe bob mary

HTML code, for reference:

<html> <head> </head> <body> <form action="/cgi-bin/testdump.pl" method=post> <table> <tr><td>Department</td> <td><input type=text name=department></td> </tr> <tr> <td colspan=2>People</td> </tr> <tr> <td colspan=2> <textarea name=people rows=5 cols=40></textarea> </td> </tr> <tr> <td><input type=submit></td> <td><input type=reset></td> </tr> </table> </form> </body> </html>

perl code, for reference:

#!/usr/bin/perl use CGI qw/:standard/; $| = 1; foreach my $field (param) { foreach my $value (param($field)) { $name .= "Names here\:\t$value<br />"; } } # Mailer section removed from OP's code for testing print header, <<EOF; <HTML> <BODY> <pre> $name </pre> </BODY> </HTML> EOF

Hope that helps.


In reply to Re^3: Processing Textarea data by atcroft
in thread Processing Textarea data 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.