Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Why are 5.10's named captures read only?

by JavaFan (Canon)
on Oct 20, 2008 at 12:14 UTC ( [id://718204]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Why are 5.10's named captures read only?
in thread Why are 5.10's named captures read only?

There are a gazillion variables "free" to choice from, unless you insist on one-character punctuation variables. Frankly, I don't think you need a one-character punctuation variable for this, and
%{^MATCH_OFFSETS}
will do fine. Personally, I'd like the values being arrays of arrays, the inner arrays 2 elements, the index of the start of the match, and the index just after the end of the match. (that is, similar to @- and @+). The outer array will hold as many captures with that name there are, so if you have:
"abc" =~ /(?<l>[a-z])(?<l>[a-z])(?<l>[a-z])/
the result is:
%{^MATCH_OFFSETS} = ('l' => [[0, 1], [1, 2], [2. 3]]);

I'm also pretty sure that if someone write a patch, it will be added to Perl.

Replies are listed 'Best First'.
Re^4: Why are 5.10's named captures read only?
by blazar (Canon) on Oct 20, 2008 at 12:55 UTC

    I personally believe it's clear enough that I don't insist but would certainly like... one-character punctuation variables which are nice, too! ;) I fully second the rest of your suggestion, BTW.

    If %- were not taken, I would have expected it to hold that kind of info. Methods would be the best thing though... I'm playing more and more with autobox but I know it doesn't fit too well in Perl 5's like typical mindset. (Apart the fact that its very docs warn about it not being real autoboxing!) And I don't know how would it square playing with such special variables as the ones we're discussing here...

    --
    If you can't understand the incipit, then please check the IPB Campaign.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://718204]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-26 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found