Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

How do you say %+ in English?

by jaldhar (Vicar)
on Feb 10, 2009 at 16:58 UTC ( #742819=perlquestion: print w/replies, xml ) Need Help??

jaldhar has asked for the wisdom of the Perl Monks concerning the following question:

I am using perl 5.10s' new named capture buffer feature to make my code more readable. It works but following the PBP guidelines, I want to use English instead of all the magic punctuation. But as far as I can tell, there is no alias for %+, the hash containing the named buffers. Am I missing something?


Replies are listed 'Best First'.
Re: How do you say %+ in English?
by ikegami (Pope) on Feb 10, 2009 at 17:07 UTC
    %LAST_PARENT_MATCH works due to an implementation side-effect (which is why the name doesn't quite fit).
    >perl -MEnglish -le"'foo' =~ /(?<n>.*)/; print $LAST_PAREN_MATCH{n}" foo

    Update: Reworded for clarity

Re: How do you say %+ in English?
by moritz (Cardinal) on Feb 10, 2009 at 17:01 UTC
    You're not missing anything, there's no English name for that.

    We had that discussion in the CB the other day, and somebody (of course I forgot who) wanted to prepare a patch for that, but I don't know if it made its way to p5p yet.

    Update: please ignore, ikegami proved me wrong. It's just missing in the documentation

    Second update: patched documentation, Rafael applied it - so it should be documented in future versions of perl.

      Thank you and ikegami for the replies. It's not clear, did Rafael document LAST_PAREN_MATCH or will there be a more appropriate name? As the whole point of this exercise is to help in maintenance, I would rather stick with %+ then use something which will change in my next update of Perl.


        They kept the name

        An alternative was suggested almost a year ago, but no action was taken.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://742819]
Approved by moritz
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2020-05-26 17:43 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (150 votes). Check out past polls.