diff options
| -rwxr-xr-x | challenge-001/bob-lied/perl/ch-1.pl | 23 | ||||
| -rwxr-xr-x | challenge-001/bob-lied/perl/ch-2.pl | 19 |
2 files changed, 42 insertions, 0 deletions
diff --git a/challenge-001/bob-lied/perl/ch-1.pl b/challenge-001/bob-lied/perl/ch-1.pl new file mode 100755 index 0000000000..ea9e3ff4f4 --- /dev/null +++ b/challenge-001/bob-lied/perl/ch-1.pl @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +# vim:set ts=4 sw=4 sts=4 et ai wm=0 nu: +#============================================================================= +# ch-1.pl +#============================================================================= +# Copyright (c) 2021, Bob Lied +#============================================================================= +# Perl Weekly Challenge 001, Task #1 Replace with E +# Write a script to replace the character ‘e’ with ‘E’ in the string +# ‘Perl Weekly Challenge’. +# Also print the number of times the character ‘e’ is found in the string. +#============================================================================= + +use strict; +use warnings; +use 5.020; + +my $s = 'Perl Weekly Challenge'; + +my $count = $s =~ tr/e/E/; + +say $s; +say $count; diff --git a/challenge-001/bob-lied/perl/ch-2.pl b/challenge-001/bob-lied/perl/ch-2.pl new file mode 100755 index 0000000000..e09e349dd1 --- /dev/null +++ b/challenge-001/bob-lied/perl/ch-2.pl @@ -0,0 +1,19 @@ +#!/usr/bin/env perl +# vim:set ts=4 sw=4 sts=4 et ai wm=0 nu: +#============================================================================= +# ch-2.pl +#============================================================================= +# Copyright (c) 2021, Bob Lied +#============================================================================= +# Perl Weekly Challenge 001, Task #2 FizzBuzz +# Write a one-liner to solve the FizzBuzz problem and print the numbers 1 +# through 20. However, any number divisible by 3 should be replaced by the +# word ‘fizz’ and any divisible by 5 by the word ‘buzz’. Those numbers that +# are both divisible by 3 and 5 become ‘fizzbuzz’. +#============================================================================= + +use strict; +use warnings; +use 5.020; + +say ($_%15==0 ? 'fizzbuzz' : $_%5==0 ? 'buzz' : $_%3==0 ? 'fizz' : $_) foreach 1..20 |
