my ($text,@words) = @_; my @text = split /\s+/, $text; my @results; for my $t (@text){ for my $w (@words){ push @results if $t eq $w; } }