aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-06-13 13:00:49 +0100
committerGitHub <noreply@github.com>2024-06-13 13:00:49 +0100
commita6786ef66f32c068262a2c03f961da603d2dc644 (patch)
tree1c9d8c429d065f5efa8d746a6e954e9887c676cc
parent3d65552202e834fd4960acb6b2127b848f1fa289 (diff)
parentf22b622d5dba4ae7ca7ac4832bc0d56d71605490 (diff)
downloadperlweeklychallenge-club-a6786ef66f32c068262a2c03f961da603d2dc644.tar.gz
perlweeklychallenge-club-a6786ef66f32c068262a2c03f961da603d2dc644.tar.bz2
perlweeklychallenge-club-a6786ef66f32c068262a2c03f961da603d2dc644.zip
Merge pull request #10254 from robbie-hatley/rh273
Update to my Perl solution to 273-1, 2024-06-12.
-rwxr-xr-xchallenge-273/robbie-hatley/perl/ch-1.pl4
1 files changed, 1 insertions, 3 deletions
diff --git a/challenge-273/robbie-hatley/perl/ch-1.pl b/challenge-273/robbie-hatley/perl/ch-1.pl
index 03c97c45fe..31b81adefd 100755
--- a/challenge-273/robbie-hatley/perl/ch-1.pl
+++ b/challenge-273/robbie-hatley/perl/ch-1.pl
@@ -71,9 +71,7 @@ Output is to STDOUT and will be each input followed by the corresponding output.
# What is the percentage, to the nearest integer,
# of a given character in a given string?
sub pct_chr_in_str ($str, $chr) {
- my $length = length($str);
- my @matches = $str =~ m/$chr/g;
- lround(100*(scalar(@matches)/$length));
+ lround(100*(scalar(@{[$str =~ m/$chr/g]})/length($str)));
}
# ------------------------------------------------------------------------------------------------------------