"be consistent" | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Dear Monks Following the suggestions I had from this node, I started coding a one liner but I can't get it to work. The problem: I have a UNIX alias file and I want to modify only root's alias, and only if it is different from a predefined one. For example:
To test if I well understanded the lesson, I created a file containing...
...and wrote a regular expression that I would eventually put into an s/// operator; I expected it to match just the second line, but the one-liner below... perl -ne '/^root:\s*(?!admin@somewhere.here)/ and print' alliasesactually outputs:
which looks quite odd to me, since I expected the first line not to match. I also tried quoting the @ sign with a backslash, \Q...\E or useing strict: no way. More oddly (to me), if I add a \s*$ at the end of the regex to match any whitespace between the address and the end of line, then no line matches!!! I am getting a little confused, where am I doing wrong? Thanks in advance, and thanks to everyone that answered to the original post Ciao! The very nature of Perl to be like natural language--inconsistant and full of dwim and special cases--makes it impossible to know it all without simply memorizing the documentation (which is not complete or totally correct anyway). In reply to On zero-width negative lookahead assertions by bronto
|
|