my @words = qw/one One/; my $pattern = 'one'; foreach (@words) { # case-sensitive so 'one' is matched but not 'One' # but I would to to be able to enable case-sensitivity # in some cases to match both 'one' and 'One' if (/$pattern/) { print "Matched: pattern was $pattern and token was $_\n"; } else { print "Unmatched: pattern was $pattern and token was $_\n"; } }