Challenge 3: Case-Insensitive Replace-All — Possible Solution ==================================================================== use strict; use warnings; use feature 'say'; my $text = "Cat sat with the cat and a CAT"; $text =~ s/cat/dog/gi; say $text; Output: dog sat with the dog and a dog WHY THIS WORKS AS AN ANSWER ------------------------------ $text =~ s/cat/dog/gi; reuses the chapter's own s/// substitution form directly, modifying $text in place (no /r modifier used here, since the challenge doesn't ask to preserve the original). The /g flag reuses the chapter's own modifier table entry — without it, s/// only replaces the FIRST match in the string, leaving "cat" and "CAT" (the second and third occurrences) untouched. With /g, all three occurrences ("Cat", "cat", "CAT") get replaced. The /i flag, also reused directly from the chapter's own modifier table, makes the match case-insensitive — without it, the pattern cat would only match the lowercase "cat" in the middle of the sentence, missing "Cat" (capitalized first letter) and "CAT" (fully uppercase) entirely. Combining both flags together (/gi) is what's required to replace every occurrence regardless of case in a single substitution call — each flag solves a different half of the problem (how MANY matches to replace, and which CASE variations count as a match), and the challenge specifically needs both at once.