RosettaCodeData/Task/CSV-to-HTML-translation/Perl/csv-to-html-translation-1.pl
Ingy döt Net 764da6cbbb CDE
2013-04-10 16:57:12 -07:00

15 lines
338 B
Perl

use HTML::Entities;
sub row {
my $elem = shift;
my @cells = map {"<$elem>$_</$elem>"} split ',', shift;
print '<tr>', @cells, "</tr>\n";
}
my ($first, @rest) = map
{my $x = $_; chomp $x; encode_entities $x}
<STDIN>;
print "<table>\n";
row @ARGV ? 'th' : 'td', $first;
row 'td', $_ foreach @rest;
print "</table>\n";