blob: aef60b4713102991fec6495c6a7e7dbb6bedc20c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/opt/perl/bin/perl
use 5.032;
use strict;
use warnings;
no warnings 'syntax';
use experimental 'signatures';
use experimental 'lexical_subs';
#
# See ../README.md
#
#
# Run as: perl ch-2.pl < input-file
#
# We make the assumption the input has the same number
# of fields on each line.
#
#
# Read in the data, split into fields, add the fields to a set strings,
# placed in an array @;. Add commas after each field.
#
map {$- = 0; $; [$- ++] .= "$_," for /[^,\n]+/g} <>;
#
# Remove trailing commas, print lines.
#
chop, say for @;
__END__
|