Re: Help! Strings -> Numbers

[email protected] (Michael Lazzaro) Fri, 22 Nov 2002 12:10:11 -0800
Newsgroups perl.perl6.documentation
Message-ID <[email protected]>
On Friday, November 22, 2002, at 10:59  AM, Luke Palmer wrote:
>> From: Michael Lazzaro <[email protected]>
>> (This is a bit off-topic, but it's a tiny bit sad that you can name
>> subrules, but you can't refer to them by name in the interpolation
>> unless you use hypothetical vars.  Eh, no biggie: it would introduce
>> too many problems to allow it.)
>
> IIRC, that's not true.  I believe this is alive and DWIMmy:
>     $s ~~ s/ <number> /$number.as(MoneyFormat)/;
>
> I know this is:
>     s/ <number> <( $number < 200 )> /

So the second half of the substitution counts as being sufficiently 
"inside" in order to grab the names from the first half?  Huh, I 
figured that would be a problem, since rules can be so heavily nested.  
Admittedly I haven't worked through it much, tho.

I've been under the impression that the following would _not_ work:

     $s ~~ /<number>/;
     print "I found $number";

but this does:

     $s ~~ /<number>/;
     print "I found $0{number}";

Right?

MikeL