aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-040/e-choroba/perl5/ch-1.pl15
-rwxr-xr-xchallenge-040/e-choroba/perl5/ch-2.pl14
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-040/e-choroba/perl5/ch-1.pl b/challenge-040/e-choroba/perl5/ch-1.pl
new file mode 100755
index 0000000000..b24139aa16
--- /dev/null
+++ b/challenge-040/e-choroba/perl5/ch-1.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use feature qw{ say };
+use utf8;
+
+binmode *STDOUT, ':encoding(UTF-8)';
+
+my @arrays = ([qw[ I L O V E Y O U ]],
+ [qw[ 2 4 0 3 2 0 1 9 ]],
+ [qw[ ! ? £ $ % ^ & * ]]);
+
+for my $i (0 .. $#{ $arrays[0] }) {
+ say join ' ', $i, map $_->[$i], @arrays;
+}
diff --git a/challenge-040/e-choroba/perl5/ch-2.pl b/challenge-040/e-choroba/perl5/ch-2.pl
new file mode 100755
index 0000000000..baaf233c9a
--- /dev/null
+++ b/challenge-040/e-choroba/perl5/ch-2.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+my @list = (10, 4, 1, 8, 12, 3);
+my @indices = (0, 2, 5);
+
+my @sorted = @list;
+@sorted[@indices] = sort { $a <=> $b } @sorted[@indices];
+
+my @expected = (1, 4, 3, 8, 12, 10);
+
+"@sorted" eq "@expected"
+ or die "Got: @sorted\nExpected: @expected\n";