in reply to Style question: regex versus string builtin function
If 'pattern' is an empty string, the last I matched regex is used.Also
You cannot include a literal $ or @ within a \Q sequence. An unescaped $ or @ interpolates the corresponding variable, while escaping will cause the literal string \$ to be matched. You'll need to write something like m/\Quser\E\@\Qhost/.The real 'style' question here, though, is Which form is most maintainable, most understandable when somebody looks at it two years from now? And this use of the $DELIMITER is going to be rather opaque in either case. Therefore, the most important element of style here is a generous set of comments, explaining why $DELIMITER was broken out a separate variable (or constant.)
throop
Update: lidden's point is well taken; even a zero-width assertion like \Q keeps the pattern from being empty. But see the discussion that follows
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Style question: regex versus string builtin function
by lidden (Curate) on Oct 02, 2007 at 12:03 UTC | |
by thospel (Hermit) on Oct 02, 2007 at 13:01 UTC | |
by kyle (Abbot) on Oct 02, 2007 at 13:55 UTC | |
by throop (Chaplain) on Oct 02, 2007 at 15:24 UTC | |
by kyle (Abbot) on Oct 02, 2007 at 15:41 UTC | |
|
Re^2: Style question: regex versus string builtin function (\Q not an assertion)
by lodin (Hermit) on Oct 14, 2007 at 22:55 UTC |