bronto has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks. This should be a simple problem, but it's 6PM here, and I think that my brain just turned itself off. But I'd like to go home with the problem solved
I'd like to have a regex to match against a UN*X aliases file; the regex should match if a line begins by root: but the string that follows it is different from, say, myself@domain.of-my.own
In short:
- root: myself@domain.of-my.own should NOT match
- anotherone: myself@domain.of-my.own should NOT match while, say,
- root: yetanother1@domain.of-my.own SHOULD match
I know it is simple, damn; I surely already wrote something like that... but that regex doesn't want to leave my brain for my keyboard...
Any help?
Thanks a lot in advance
Update: I have to feed the regexp into an editfiles section of cfengine; I need to do the job with a single, standard regex
Update: Unfortunately cfengine has no support for PCREs, so if the problem has no solution with plain-old regexes (does it?), I'll have to change the way I work with the problem (by, for example, spawning an external perl -i.bak one-liner. Thanks to everyone of you that took the time to suggest a solution!
Update: Actually, the people of the cfengine have already considered linking against libpcre instead of libre, but nobody come out with a working patch for both the source and the compiler's options. If any monk is able to, that could be great for both cfengine (a great improvement IMHO) and Perl (another conquer, Captain! :-)
Ciao!
--bronto
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).
--John M. Dlugosz
|
---|