Re: RFC 112 (v2) Assignment within a regex

[email protected] (Nathan Wiger)
Newsgroups perl.perl6.language.regex
Message-ID <[email protected]>
>    if (/Time: (..):(..):(..)/) {
>         $hours = $1;
>         $minutes = $2;
>         $seconds = $3;
>     }
> 
> This then becomes:
> 
>   /Time: (?$hours=..):(?$minutes=..):(?$seconds=..)/
> 
> This is more maintainable than counting the brackets and easier to understand
> for a complex regex.  And one does not have to worry about the scope of $1 etc.

This is probably one of the coolest RFC's I've seen so far. :-) 

One question: How are these scoped? Are they lexicals? Global dynamics?
What if you want to change the scoping?

This is the only catch I see. Maybe requiring, under 'use strict':

   my($hours, $minutes, $seconds);
   /Time: (?$hours=..):(?$minutes=..):(?$seconds=..)/

Input?

-Nate
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.