CSV to HTML translation: Difference between revisions
→{{header|Perl 6}}: restrucured the code and removed the optional part, since it didn't work anyway.
(→{{header|Perl 6}}: added some comments) |
(→{{header|Perl 6}}: restrucured the code and removed the optional part, since it didn't work anyway.) |
||
Line 1,923:
=={{header|Perl 6}}==
Line 1,934 ⟶ 1,932:
Brians mother,I'm his mother; that's who!
The multitude,Behold his mother! Behold his mother!¦;
# comment the next line out, if you want to read from standard input instead of the hard-coded $str above
# my $str = $*IN.slurp;
my &escape = *.trans([ <& < \>>] => [<& < >> ]); # a function with one argument that escapes the entities
my &tag = {"<$^
printf
'<!DOCTYPE html>
<html>
Line 1,945 ⟶ 1,947:
%s
</table></body></html>
', [~] # concatenation reduction ('a', 'b', 'c') → 'abc'
==>
# that / at the end is just an unspace, you can omit it, but then you have to delete
# all whitespace and comments between split(…) and .map
.map({tag 'td', $^cell})) }); # map those cells as td
</lang>
|