aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrobbie-hatley <Robbie.Hatley@gmail.com>2024-06-12 07:18:39 -0700
committerrobbie-hatley <Robbie.Hatley@gmail.com>2024-06-12 07:18:39 -0700
commitf22b622d5dba4ae7ca7ac4832bc0d56d71605490 (patch)
treed92e34ae4d9900027f51716a7500e8ae9b840688
parent9b0d62f010c7cbfaadbad2358b208acb9af7dd56 (diff)
downloadperlweeklychallenge-club-f22b622d5dba4ae7ca7ac4832bc0d56d71605490.tar.gz
perlweeklychallenge-club-f22b622d5dba4ae7ca7ac4832bc0d56d71605490.tar.bz2
perlweeklychallenge-club-f22b622d5dba4ae7ca7ac4832bc0d56d71605490.zip
Updates, 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)));
}
# ------------------------------------------------------------------------------------------------------------