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 |
Test | HTML code | Displayed |
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. |