tlhackque has asked for the wisdom of the Perl Monks concerning the following question:
What are the rules? And what's the best idiom for influencing the outcome?
For example, consider /foo$.*^bar/ms - is this $. (the variable) or EOL followed by random stuff?
I find myself introducing non-capturing parens, as it seems that if a paren can be matched it won't be used as a variable name.
A more realistic example:
$QQ->get_private_key_string =~ /(^-----BEGIN (?:(RSA) )?PRIVATE KEY-----$(?:.*)^-----END (?:RSA )?PRIVATE KEY-----$(?:\s*))/ms;
This gets quite entertaining, considering that $. $( and $) are variables.
It would be nice to have a deterministic way to code these cases. And may I suggest that this should be documented?
Thanks.This communication may not represent my employer's views, if any, on the matters discussed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Disambuating $ in (especially /m) regexps
by Eily (Monsignor) on Jan 05, 2016 at 12:44 UTC | |
by tlhackque (Beadle) on Jan 05, 2016 at 12:56 UTC | |
by BillKSmith (Monsignor) on Jan 05, 2016 at 22:04 UTC | |
|
Re: Disambuating $ in (especially /m) regexps
by choroba (Cardinal) on Jan 05, 2016 at 13:14 UTC | |
|
Re: Disambuating $ in (especially /m) regexps
by Your Mother (Archbishop) on Jan 05, 2016 at 12:26 UTC | |
by tlhackque (Beadle) on Jan 05, 2016 at 12:49 UTC | |
|
Re: Disambuating $ in (especially /m) regexps
by Anonymous Monk on Jan 05, 2016 at 16:26 UTC | |
|
Re: Disambuating $ in (especially /m) regexps
by Anonymous Monk on Jan 05, 2016 at 11:29 UTC | |
|
Re: Disambuating $ in (especially /m) regexps
by ikegami (Patriarch) on Jan 06, 2016 at 18:41 UTC |