diff options
| author | Ailbhe Tweedie <atweedie@protonmail.ch> | 2019-04-02 11:14:44 +0200 |
|---|---|---|
| committer | Ailbhe Tweedie <atweedie@protonmail.ch> | 2019-04-03 01:08:20 +0200 |
| commit | 4606c1fea1d63e7fcda943f7f1a34932d97b1983 (patch) | |
| tree | b120af6643ccce94bec8823a1db078bbd693e96c /challenge-001 | |
| parent | 1a4b6a31486c3cc891dc96b7b50934e649e3c05d (diff) | |
| download | perlweeklychallenge-club-4606c1fea1d63e7fcda943f7f1a34932d97b1983.tar.gz perlweeklychallenge-club-4606c1fea1d63e7fcda943f7f1a34932d97b1983.tar.bz2 perlweeklychallenge-club-4606c1fea1d63e7fcda943f7f1a34932d97b1983.zip | |
add solution for week 1, ch-01
Diffstat (limited to 'challenge-001')
| -rw-r--r-- | challenge-001/ailbhe-tweedie/README | 1 | ||||
| -rwxr-xr-x | challenge-001/ailbhe-tweedie/perl5/ch-01.pl | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/challenge-001/ailbhe-tweedie/README b/challenge-001/ailbhe-tweedie/README new file mode 100644 index 0000000000..36d4034b70 --- /dev/null +++ b/challenge-001/ailbhe-tweedie/README @@ -0,0 +1 @@ +Solution by Ailbhe Tweedie diff --git a/challenge-001/ailbhe-tweedie/perl5/ch-01.pl b/challenge-001/ailbhe-tweedie/perl5/ch-01.pl new file mode 100755 index 0000000000..22c1d97107 --- /dev/null +++ b/challenge-001/ailbhe-tweedie/perl5/ch-01.pl @@ -0,0 +1,14 @@ +#!/usr/bin/perl +# +# 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 $string = 'Perl Weekly Challenge'; +my $numberOfEs; +while ($string =~ /\G[^e]*e/g) { + $numberOfEs++; +} +print "Es: $numberOfEs\n"; +my $replaced = $string =~ s/e/E/g; +print "replaced: $replaced"; |
