aboutsummaryrefslogtreecommitdiff
path: root/challenge-070
diff options
context:
space:
mode:
authorFung Cheok Yin <61836418+E7-87-83@users.noreply.github.com>2020-07-26 18:23:07 +0800
committerGitHub <noreply@github.com>2020-07-26 18:23:07 +0800
commit35855be4081a45bf62dd22aa81005b3d50cae802 (patch)
tree62da276d2d5a248c3ad9646a40205bf31508646c /challenge-070
parent0801107ed8666794d35b3cb23f72bdfdad6d0120 (diff)
downloadperlweeklychallenge-club-35855be4081a45bf62dd22aa81005b3d50cae802.tar.gz
perlweeklychallenge-club-35855be4081a45bf62dd22aa81005b3d50cae802.tar.bz2
perlweeklychallenge-club-35855be4081a45bf62dd22aa81005b3d50cae802.zip
Add files via upload
Diffstat (limited to 'challenge-070')
-rw-r--r--challenge-070/cheok-yin-fung/ch-1.pl22
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-070/cheok-yin-fung/ch-1.pl b/challenge-070/cheok-yin-fung/ch-1.pl
new file mode 100644
index 0000000000..109c39195d
--- /dev/null
+++ b/challenge-070/cheok-yin-fung/ch-1.pl
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+# Perl Weekly Challenge #070 Task 1 Character Swapping
+# Usage: ch-1.pl [string] [swap count] [offset]
+
+my $s = 'perlandraku';
+my $C = 3;
+my $O = 4;
+
+if ($ARGV[0] and $ARGV[1] and $ARGV[2]) {
+ $s = $ARGV[0];
+ $C = $ARGV[1];
+ $O = $ARGV[2];
+}
+
+my $N = length $S;
+
+for my $counter (1..$C) {
+ my $t = substr $s, $counter, 1;
+ my $z = substr($s, $counter+$O, 1, $t);
+ substr $s, $counter, 1, $z;
+ print $counter, " ", $s, "\n";
+}