diff options
| author | Abigail <abigail@abigail.be> | 2021-01-26 01:13:15 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-01-26 12:07:41 +0100 |
| commit | 1889deddca521e1aa013d53a749c693c6589deba (patch) | |
| tree | 74ad27d14ee32de3ad6a5afdd04f895a280ddf10 | |
| parent | 6c5715542385de49f20d0f56d1c9aa66b5736cab (diff) | |
| download | perlweeklychallenge-club-1889deddca521e1aa013d53a749c693c6589deba.tar.gz perlweeklychallenge-club-1889deddca521e1aa013d53a749c693c6589deba.tar.bz2 perlweeklychallenge-club-1889deddca521e1aa013d53a749c693c6589deba.zip | |
Use an option to determine the shift size.
| -rw-r--r-- | challenge-097/abigail/perl/ch-1.pl | 16 | ||||
| -rw-r--r-- | challenge-097/abigail/t/ctest.ini | 3 | ||||
| -rw-r--r-- | challenge-097/abigail/t/input-1-1 | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/challenge-097/abigail/perl/ch-1.pl b/challenge-097/abigail/perl/ch-1.pl index 9ffda0a6e5..eabc49db2c 100644 --- a/challenge-097/abigail/perl/ch-1.pl +++ b/challenge-097/abigail/perl/ch-1.pl @@ -14,13 +14,19 @@ use experimental 'lexical_subs'; # # -# Run as: perl ch-1.pl < input-file +# Run as: perl ch-1.pl -t TIMES < input-file # +use Getopt::Long; + +GetOptions 't=i' => \my $times; + +die "-t option required" unless defined $times; + +$times %= 26; + while (<>) { chomp; - my ($times, $plain) = split ' ', $_, 2; - $times %= 26; - $plain =~ y/A-Z/ZA-Y/ for 1 .. $times; - say $plain; + s/([A-Z])/my $ch = ord ($1) - $times; $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 0ae9d07567..8fee647f8b 100644 --- a/challenge-097/abigail/t/ctest.ini +++ b/challenge-097/abigail/t/ctest.ini @@ -1,3 +1,6 @@ [names]
1-1 = Given example
2-1 = Given examples
+
+[1-1]
+args = -t 3
diff --git a/challenge-097/abigail/t/input-1-1 b/challenge-097/abigail/t/input-1-1 index 6c3d28d154..678239264e 100644 --- a/challenge-097/abigail/t/input-1-1 +++ b/challenge-097/abigail/t/input-1-1 @@ -1 +1 @@ -3 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG +THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG |
