Your skill will accomplish what the force of many cannot |
|
PerlMonks |
%{^CAPTURE}, %{^CAPTURE_ALL} and %- don't produce expected outputby vr (Curate) |
on Jun 11, 2019 at 17:39 UTC ( [id://11101258]=perlquestion: print w/replies, xml ) | Need Help?? |
vr has asked for the wisdom of the Perl Monks concerning the following question:
Documentation is not very verbose about new %{^CAPTURE}, %{^CAPTURE_ALL} variables, they are listed as if they are English synonyms to old %+ and %-, but they are obviously not, they look plain wrong to me. The "aaa" was deleted from @{^CAPTURE} array (or was not even added to begin with), when rightmost cluster failed to match, and deleted as array element from @{$-{a}}, but the $#{$-{a}} was not changed from wrong 2 to expected 1, hence unexpected undefined element in @{$-{a}}. Update: Actually, w/r/t %-, re-reading the docs, there's no phrase "all defined "a"'s groups" as I stated above. To each capture group name found in the regular expression, it associates a reference to an array containing the list of values captured by all buffers with that name (should there be several of them), in the order where they appear. Yes, they say "all buffers with that name", but can undef be said to be "captured"? Can failed sub-expression "capture"? It's ambiguous. Update 2: Mixing these "CAPTURE" things is broken:
is OK, but un-commenting 1st line results in empty unblessed hash in the 2nd.
Back to
Seekers of Perl Wisdom
|
|