in reply to How to club different lines of program into one

One possible approach:
>perl -wMstrict -le "my @terms = qw(january foo february egypt moon saturday bar); my $search = qr{ @{[ join '|', @terms ]} }xms; my $str = 'in february the moon is not visible in egypt on saturday night'; my %count; ++$count{$1} while $str =~ m{ ($search) }xmsg; for my $term (@terms) { print qq{$term is }, $count{$term} ? '' : 'NOT ', 'present'; } " january is NOT present foo is NOT present february is present egypt is present moon is present saturday is present bar is NOT present