perl negative look behind with groupings
- by user1539348
I have a problem trying to get a certain match to work with negative look behind
example
@list = qw( apple banana cherry);
$comb_tlist = join ("|", @tlist);
$string1 = "include $(dir)/apple";
$string2 = "#include $(dir)/apple";
if( string1 =~ /^(?<!#).*($comb_tlist)/) #matching regex I tried, works
The array holds a set of variables that is matched against the string.
I need the regex to match $string1, but not $string2.
It matches $string1, but it ALSO matches $string2. Can anyone tell me what I am attempting wrong here. Thanks!