diff options
| author | Abigail <abigail@abigail.be> | 2021-01-26 01:53:18 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-01-26 12:07:41 +0100 |
| commit | 3a68dc14c70c709ea8097e98e38931ef93e643af (patch) | |
| tree | ded81f35239c77dea4d19c1027ec664cc8cff6d8 /challenge-097 | |
| parent | 1889deddca521e1aa013d53a749c693c6589deba (diff) | |
| download | perlweeklychallenge-club-3a68dc14c70c709ea8097e98e38931ef93e643af.tar.gz perlweeklychallenge-club-3a68dc14c70c709ea8097e98e38931ef93e643af.tar.bz2 perlweeklychallenge-club-3a68dc14c70c709ea8097e98e38931ef93e643af.zip | |
Use option -s (shift), instead of -t.
Diffstat (limited to 'challenge-097')
| -rw-r--r-- | challenge-097/abigail/README.md | 5 | ||||
| -rw-r--r-- | challenge-097/abigail/perl/ch-1.pl | 10 | ||||
| -rw-r--r-- | challenge-097/abigail/t/ctest.ini | 2 |
3 files changed, 11 insertions, 6 deletions
diff --git a/challenge-097/abigail/README.md b/challenge-097/abigail/README.md index 4c9207dc23..9eec07616d 100644 --- a/challenge-097/abigail/README.md +++ b/challenge-097/abigail/README.md @@ -19,7 +19,12 @@ Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD ~~~~ +### Note +We will be reading the plain text from STDIN, and use an option (-s) +to indicate the left shift. + ### Solutions +* [Node.js](node/ch-1.js) * [Perl](perl/ch-1.pl) ### Blog diff --git a/challenge-097/abigail/perl/ch-1.pl b/challenge-097/abigail/perl/ch-1.pl index eabc49db2c..9a94c07550 100644 --- a/challenge-097/abigail/perl/ch-1.pl +++ b/challenge-097/abigail/perl/ch-1.pl @@ -14,19 +14,19 @@ use experimental 'lexical_subs'; # # -# Run as: perl ch-1.pl -t TIMES < input-file +# Run as: perl ch-1.pl -s TIMES < input-file # use Getopt::Long; -GetOptions 't=i' => \my $times; +GetOptions 's=i' => \my $shift; -die "-t option required" unless defined $times; +die "-s option required" unless defined $shift; -$times %= 26; +$shift %= 26; while (<>) { chomp; - s/([A-Z])/my $ch = ord ($1) - $times; $ch += 26 if $ch < 65; chr $ch/eg; + s/([A-Z])/my $ch = ord ($1) - $shift; $ch += 26 if $ch < 65; chr $ch/eg; say; } diff --git a/challenge-097/abigail/t/ctest.ini b/challenge-097/abigail/t/ctest.ini index 8fee647f8b..886776f178 100644 --- a/challenge-097/abigail/t/ctest.ini +++ b/challenge-097/abigail/t/ctest.ini @@ -3,4 +3,4 @@ 2-1 = Given examples
[1-1]
-args = -t 3
+args = -s 3
|
