in reply to Pushing to an array

Turn the list of folders into a single regex, then do your test. Add boundary conditions to the regex as required.
#!/usr/bin/perl -w use strict; use warnings; my @folders = qw(inc Inc iNc incr src Src); my $folders_re = join '|', map {quotemeta} @folders; my $mk = "./media/common/max/tail/common.mk: $(PROJECT_ROOT)/../../ +Utils/inC"; my @folder_match; if ($mk !~ /$folders_re/i) { push @folder_match ,$mk; } print "@folder_match\n";