From f22b622d5dba4ae7ca7ac4832bc0d56d71605490 Mon Sep 17 00:00:00 2001 From: robbie-hatley Date: Wed, 12 Jun 2024 07:18:39 -0700 Subject: Updates, 2024-06-12. --- challenge-273/robbie-hatley/perl/ch-1.pl | 4 +--- 1 file changed, 1 insertion(+), 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))); } # ------------------------------------------------------------------------------------------------------------ -- cgit