in reply to assertions help
$str =~ s/\n^#ifdef\s+(\S+)\s*$(.*?)\n*(?:(?:^#else$)(.*?))?\n*^#endif$/{$1 eq $macro ? $2 : $3}/igsme;
I had missed the /e modifier after all these years, would have been useful in the past.I haven't used the minimal match or the no-capture options, but then not missed them.
The above solution works very well and fast, so I'm very pleased with that.
On the comment of nesting, I'm processing exisitng files, none of which use nesting and so I can state in my docs that nesting isn't supported, going forwards. I don't think there will be a need for it in my circumstances.
|
|---|