http://qs321.pair.com?node_id=390085


in reply to On zero-width negative lookahead assertions

First, don't forget to escape @ and ..

>perl -lne "/^root:\s*(?!admin\@somewhere\.here)(.*)/ and print $1" \ aliases.txt someone@somewhere.else admin@somewhere.here

Note the leading space. When the regexp engine failed using all the spaces, it backtracked to \s* matching all but one space. One way to fix it is to anchor it as follows:

>perl -ne "/^root:\s*(?!admin\@somewhere\.here)\S/ and print;" \ aliases.txt root: someone@somewhere.else