HTML rendering ignores multiple whitespace and newlines and renders as a single space. You can either specify a Content-Type of text/plain or you can wrap your stuff in <PRE> tags which specify preformatted text ie fixed width, render the spaces as expected.
Given that you have the power of HTML to hand you could just do a nice table.
#!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; my @rows = join '', map{"<td>$_</td>"}('router ip', 'sip','dip','sif', +'dif','proto','sport','dport','pkts','size'); for (@sort_result) { my @tmpdata = split /\|/; push @rows, join '', map{"<td>$_</td>"} @tmpdata[0..7], $flows{$_} +{pkts}, $flows{$_}{size}; } @rows = map{ "<tr>$_</tr>\n" } @rows; print "<table border=1>\n" , @rows, "</table>";
cheers
tachyon
In reply to Re: How to format cgi output?
by tachyon
in thread How to format cgi output?
by iwanthome
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |