aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-110/wlmb/blog.txt1
-rwxr-xr-xchallenge-110/wlmb/perl/ch-1.pl10
-rwxr-xr-xchallenge-110/wlmb/perl/ch-2.pl11
-rwxr-xr-xchallenge-110/wlmb/perl/ch-2a.pl15
4 files changed, 37 insertions, 0 deletions
diff --git a/challenge-110/wlmb/blog.txt b/challenge-110/wlmb/blog.txt
new file mode 100644
index 0000000000..3764858532
--- /dev/null
+++ b/challenge-110/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2021/04/27/PWC110/
diff --git a/challenge-110/wlmb/perl/ch-1.pl b/challenge-110/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..a8b9bca7f1
--- /dev/null
+++ b/challenge-110/wlmb/perl/ch-1.pl
@@ -0,0 +1,10 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 110
+# Task 2: Valid phone numbers
+#
+# See https://wlmb.github.io/2021/04/27/PWC110/#task-1-valid-phone-numbers
+use strict;
+use warnings;
+use v5.12;
+my $pattern= join '|', map {qr(^\s*$_\s*$)} qw(\+\d{2}\s\d{10} \\(\d{2}\\)\s\d{10} \d{4}\s\d{10});
+print "Output:\n", grep {$_=~$pattern} <>;
diff --git a/challenge-110/wlmb/perl/ch-2.pl b/challenge-110/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..d9eca28023
--- /dev/null
+++ b/challenge-110/wlmb/perl/ch-2.pl
@@ -0,0 +1,11 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 110
+# Task 2: Transpose file
+#
+# Simple version
+# See https://wlmb.github.io/2021/04/27/PWC110/#task-2-transpose-file
+use strict;
+use warnings;
+use v5.12;
+my @input=map {chomp; [split /,/]} <>;
+say join "\n", map { my $c=$_; join ",", map {$input[$_][$c]} 0..@input-1} 0..scalar @{$input[0]}-1;
diff --git a/challenge-110/wlmb/perl/ch-2a.pl b/challenge-110/wlmb/perl/ch-2a.pl
new file mode 100755
index 0000000000..1363368231
--- /dev/null
+++ b/challenge-110/wlmb/perl/ch-2a.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 110
+# Task 2: Transpose file
+#
+# CSV version
+# See https://wlmb.github.io/2021/04/27/PWC110/#task-2-transpose-file
+use strict;
+use warnings;
+use v5.12;
+use List::Util qw(max);
+use Text::CSV qw(csv);
+my $input=csv(in=>*ARGV);
+my $Ncols=max map {scalar @{$input->[$_]}} @$input-1;
+my $transposed=[map {my $c=$_; [map {$input->[$_][$c]} 0..@$input-1]} 0..$Ncols-1];
+csv(in=>$transposed, out=>*STDOUT, eol=>$/);