Perl Weekly Challenge 230: Count Words
These are some answers to the Week 230, Task 2, of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a few days from now (on August 20, 2023 at 23:59). This blog post offers some solutions to this challenge. Please don’t read on if you intend to complete the challenge on your own.
Task 2: Count Words
You are given an array of words made up of alphabetic characters and a prefix.
Write a script to return the count of words that starts with the given prefix.
Example 1
Input: @words = ("pay", "attention", "practice", "attend")
$prefix = "at"
Ouput: 2
Two words "attention" and "attend" starts with the given prefix "at".
Example 2