in reply to GREP/Regex - Locating Words in Sentences
my @words = qw(foo bar); my @sentences = ( "let's say we have a function called foo", "I'm going to the bar", ); for my $word (@words) { @occurrences = grep /\b$word\b/, @sentences; print "$word occurs in ", join("\n", @occurrences), "\n"; }
--
:wq
|
|---|