> but friend wrote to me, that with perl 5.20 he gained something wrong (warning/error).
Couldn't you make this clear from the beginning?
> don't have access to code,
Then please reproduce it next time.
| [reply] |
To by honest, I don't remember. And it is possible that I used that construct redundantly or I used it with wrong faith that after possessive quantifier succeeds then all backtrackings are disabled from this point (but for real backtrackings are disabled only in that group).
Today I failed to imagine practical example where this atomic/possessive construct could be used.
| [reply] |
So I accessed today to the code.
It was a regular expression which tries to match (number1) with (measuring units1){optional}, and (number2 with units2){optional}.
The shortened for simplicity regex looks like that:
/^
(?: ' \s* )?
($positive_number){1}+ \s* (?: \( \s* ($stdev) \s* \) )?
\s* ($units_1)?
(
\s* ($positive_number) \s* (?: \( \s* ($stdev) \s* \) )?
\s* ($units_2)
)?
(?: \s* ' )?
$/x
For example: $units_1 = "A|B3"; $units_2 = "C|D-3";
Then regex should match:
20B3
20 B3 15 D-3
20A15C
but it shouldn't match 20C.
With new backtracking it matches 20C as (2, undef, undef, 0, undef, C) === ($1, $2, $3, $4, $5, $6)
| [reply] [d/l] [select] |
Well the question seems answered now, its a bug from 5.20 onwards.
(?>...) still works like expected (and its better readable IMHO)
Seems like someone thought there should be a (erroneous) warning
and patched the code.
The perldoc mentioning redundancy might have paved the way for accepting this patch too easily.
I'm surprised there was no unit test that alarmed p5p.
| [reply] [d/l] |