diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-02-23 18:28:23 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-23 18:28:23 +0000 |
| commit | 4e8d15e91fa1da7b1d33cc8f946e317b677300b4 (patch) | |
| tree | 688074a0d0de3bb7225c17d11af98a01078241cf | |
| parent | 2c26164a5a90aa14a19078d845769d3ec9fbb5ae (diff) | |
| parent | 4b6c7073bed9f8409177ccc76198967ab38bcaec (diff) | |
| download | perlweeklychallenge-club-4e8d15e91fa1da7b1d33cc8f946e317b677300b4.tar.gz perlweeklychallenge-club-4e8d15e91fa1da7b1d33cc8f946e317b677300b4.tar.bz2 perlweeklychallenge-club-4e8d15e91fa1da7b1d33cc8f946e317b677300b4.zip | |
Merge pull request #3600 from boblied/master
PWC 001 late to the party
| -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 |
