> : Would something like these DWIM? > : > : # match pat1 _ pat2 and capture pat2 match: > : / pat1 { ($foo) = / pat2 / } / > > Yes
So a match in a closure starts where the outer match was. Simple enough. Will: # match pat1 _ pat2 _ pat3 and capture pat2 match: / pat1 { ($foo) = / pat2 / } pat3 / work? > I don't think the return of the closure will be interpreted as > [a string to be matched or a boolean success indicator or > indeed anything, at least not something that the regex > pays attention to]. Closures will be used for side effects, > and I'd hate to see a lot of closures ending in a cryptic C<0;>. Right. Here's a thought, no need to respond just yet: Perhaps the regex could look to see if the return value has one of a set of properties. If it does not, the regex ignores the return value. Otherwise it uses the value in accord with the property: # match pat1 _ 'foo bar': / pat1 { 'foo bar' is pat } / Not exactly a compelling example, but the point is this might be an appropriate way for closure return values to participate in regex matching operation. Aiui, one has regular perl code (not regex) read access to what is *matched by* a parens, but not write access to the *matching of* a parens. So, one can do: / pat1 ( pat2 ) { $foo = $-1 } / to read the value, but not # made up, no thought applied, syntax # match pat1 _ pat2 _ pat2 / pat1 { .match 2 } ( pat2 ) / where .match is followed by an expression that applies some control to the next parens. I'm out of my depth here, but can you see what I'm trying to get to? To see how far one can have closures, and hence regular perl syntax, take on regex control duties. -- ralph