http://www.perlmonks.org?node_id=1018345

SirClive has asked for the wisdom of the Perl Monks concerning the following question:

In the code below I an trying to test for 'contains bar or Bar but doesn't start with fee' . But I get rows 4 and 5 returned as well as 2 and 3 . What am I doing wrong ?
use strict; use warnings; while(my $line = <DATA>) { chomp($line); if( $line =~ /(?<!fee).*[Bb]ar.*\.java/ ) { print $line . "\n"; } } __DATA__ foo/src/com/stuff/xxxxxx.java foo/src/com/stuff/ggbargg.java foo/src/com/stuff/ggBargg.java fee/src/com/stuff/ggbargg.java fee/src/com/stuff/ggBargg.java
Thanks