my $text = "I am going to walk to the park."; for ($text =~ /(\w+)/g) { if (lc $_ eq "walk") { print "Walking is good for you\n"; } elsif (lc $_ eq "park") { print "Parks are fun\n"; } }