We don't bite newbies here... much | |
PerlMonks |
Re^4: Filename change with regular expressionby Laurent_R (Canon) |
on Aug 09, 2013 at 21:51 UTC ( [id://1048854]=note: print w/replies, xml ) | Need Help?? |
Other than decreasing readability and maintainability of the code, I see no purpose of having it as a single regular expression. I definitely agree. It is often much better to have several regexes is a row, for example to just get rid of all exceptions and special cases, before the regex doing the actual work, rather than trying to pack everything into a single complicated regex. For example, suppose that you don't want to apply your substitution on file lines that start with XYZ, contain ZYX or XZY or end with YZZ. Trying to put all this in your single s/// substitution is quickly becoming a nighmare, while something like this is very clear:
In the case of the OP, this might be something like this:
In Section
Seekers of Perl Wisdom
|
|