diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-04-04 10:59:16 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-04 10:59:16 +0100 |
| commit | d32d8bcf6bfe6b3c405e2713c0a8c23892d585c5 (patch) | |
| tree | 198187fd7e86d08f528ecf9d685354f9db1fa2a6 | |
| parent | d75855c75d89677d8af35a1dee75093524eb259f (diff) | |
| parent | 3abeddeb2a6e6eb0074879ec3cf6c67c36952467 (diff) | |
| download | perlweeklychallenge-club-d32d8bcf6bfe6b3c405e2713c0a8c23892d585c5.tar.gz perlweeklychallenge-club-d32d8bcf6bfe6b3c405e2713c0a8c23892d585c5.tar.bz2 perlweeklychallenge-club-d32d8bcf6bfe6b3c405e2713c0a8c23892d585c5.zip | |
Merge pull request #12 from adamcrussell/master
Added solution for challenge-001.
| -rw-r--r-- | challenge-001/adam-russell/perl5/ch-1.pl | 14 | ||||
| -rw-r--r-- | challenge-001/adam-russell/perl5/ch-2.pl | 28 |
2 files changed, 42 insertions, 0 deletions
diff --git a/challenge-001/adam-russell/perl5/ch-1.pl b/challenge-001/adam-russell/perl5/ch-1.pl index fc34504e9d..af82fa4dc8 100644 --- a/challenge-001/adam-russell/perl5/ch-1.pl +++ b/challenge-001/adam-russell/perl5/ch-1.pl @@ -1,4 +1,17 @@ use strict; +<<<<<<< HEAD +use warnings; +## +# Challenge #1 +# 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. +## +my $challenge_string="Perl Weekly Challenge"; +my $number=do{ + $challenge_string=~tr/e/E/ +}; +print "$number $challenge_string\n"; +======= use warnings; ## # Challenge #1 @@ -10,3 +23,4 @@ my $number = do { $challenge_string =~ tr/e/E/; }; print "$number $challenge_string\n"; +>>>>>>> upstream/master diff --git a/challenge-001/adam-russell/perl5/ch-2.pl b/challenge-001/adam-russell/perl5/ch-2.pl index 6d8719ed05..4dfebdfbe3 100644 --- a/challenge-001/adam-russell/perl5/ch-2.pl +++ b/challenge-001/adam-russell/perl5/ch-2.pl @@ -1,4 +1,31 @@ use strict; +<<<<<<< HEAD +use warnings; +## +# Challenge #2 +# Write one-liner to solve FizzBuzz problem and print number 1-20. +# However, any number divisible by 3 should be replaced by the word fizz +# and any divisible by 5 by the word buzz. Numbers divisible by both become fizz buzz. +## +use experimental q/switch/; +my $i = 1; +{ + given($i){ + when($i % 3 == 0 && $i % 5 == 0){ + print "fizz buzz\n"; + } + when($i % 5 == 0){ + print "buzz\n"; + } + when($i % 3 == 0){ + print "fizz\n"; + } + default{ + print "$i\n"; + } + } + $i++; +======= use warnings; ## # Challenge #2 @@ -24,5 +51,6 @@ my $i = 1; } } $i++; +>>>>>>> upstream/master redo until ($i > 20); } |
