in reply to Re^4: reg expression question
in thread reg expression question
You are right, when used in a regex without an /m modifier, ^ means “match the beginning of the string,” and is equivalent to \A. “Match at the beginning of the line” (which is the definition given in perlre#Regular-Expressions) is strictly correct only when ^ is used in a regex with an /m modifier. So maybe this part of the documentation should be re-worded?
I haven’t used Perl::Critic, and as to this particular policy — well, I’m suspicious of guidelines that say “always do X” regardless of context. In the present case, adding an /m modifier to the regex would, IMO, be misleading, as it would imply (or at least suggest) that the string being matched is expected to contain multiple newlines. But I acknowledge that this is a judgment call, and YMMV.
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: reg expression question
by AnomalousMonk (Archbishop) on Jan 29, 2015 at 11:14 UTC | |
by healingtao (Novice) on Jan 29, 2015 at 16:04 UTC | |
by Athanasius (Archbishop) on Jan 29, 2015 at 16:53 UTC | |
by healingtao (Novice) on Jan 29, 2015 at 18:13 UTC |