diff options
| -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); } |
