aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)));
}
# ------------------------------------------------------------------------------------------------------------