diff options
| -rw-r--r-- | challenge-070/cheok-yin-fung/ch-1.pl | 22 |
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"; +} |
