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


in reply to Having a problem with negative look behind assertion

You don't have fixed width of line, look behind or look ahead will only work on fixed width

use strict; use warnings; while(my $line = <DATA>) { chomp($line); if( $line =~ /(?<!fee\/src\/)(com\/)/ ) { print $line . "\n"; } } __DATA__ foo/src/com/ foo/src/com/ foo/src/com/ fee/src/com/

Replies are listed 'Best First'.
Re^2: Having a problem with negative look behind assertion
by ww (Archbishop) on Feb 13, 2013 at 00:10 UTC
    Sorry, but that's half wrong. See perldoc perlretut which makes it very clear: look aheads need NOT be fixed width; only the look behind flavor.

    If you didn't program your executable by toggling in binary, it wasn't really programming!