Numification of captured match

2005-05-12 Thread Autrijus Tang
Thit has led to surprising results in Pugs's Net::IRC: if 'localhost:80' ~~ /^(.+)\:(\d+)$/ { my $socket = connect($0, $1); } If $1 is a match object here, and connect() assumes Int on its second argument, then it will connect to port 1, as the match object numifies to 1

Re: Numification of captured match

2005-05-12 Thread Patrick R. Michaud
On Fri, May 13, 2005 at 03:23:20AM +0800, Autrijus Tang wrote: Is it really intended that we get into habit of writing this? if 'localhost:80' ~~ /^(.+)\:(\d+)$/ { my $socket = connect(~$0, +$1); } It looks... weird. :) And it would have to be if 'localhost:80' ~~

Re: Numification of captured match

2005-05-12 Thread Jonathan Scott Duff
On Thu, May 12, 2005 at 02:55:36PM -0500, Patrick R. Michaud wrote: On Fri, May 13, 2005 at 03:23:20AM +0800, Autrijus Tang wrote: Is it really intended that we get into habit of writing this? if 'localhost:80' ~~ /^(.+)\:(\d+)$/ { my $socket = connect(~$0, +$1); } It

Re: Numification of captured match

2005-05-12 Thread Rob Kinyon
On 5/12/05, Jonathan Scott Duff [EMAIL PROTECTED] wrote: On Thu, May 12, 2005 at 02:55:36PM -0500, Patrick R. Michaud wrote: On Fri, May 13, 2005 at 03:23:20AM +0800, Autrijus Tang wrote: Is it really intended that we get into habit of writing this? if 'localhost:80' ~~

Re: Numification of captured match

2005-05-12 Thread Larry Wall
On Thu, May 12, 2005 at 02:55:36PM -0500, Patrick R. Michaud wrote: : On Fri, May 13, 2005 at 03:23:20AM +0800, Autrijus Tang wrote: : Is it really intended that we get into habit of writing this? : : if 'localhost:80' ~~ /^(.+)\:(\d+)$/ { : my $socket = connect(~$0, +$1); : } :

Re: Numification of captured match

2005-05-12 Thread Damian Conway
Larry Wall wrote: I think we already said something like that once some number of months ago. +$1 simply has to be the numeric value of the match. Agreed. Anyway, while we could have a method for the .matchcount, +$1[] should work fine too. Yep. Actually, it's not clear to me offhand why @1

Re: Numification of captured match

2005-05-12 Thread Larry Wall
On Fri, May 13, 2005 at 02:00:10PM +1000, Damian Conway wrote: : Actually, it's not clear to me offhand why @1 shouldn't mean $1[] : and %1 shouldn't mean $1{}. : : It *does*. According to the recent capture semantics document: : : Note that, outside a rule, C@1 is simply a shorthand for

Re: Numification of captured match

2005-05-12 Thread Jonathan Scott Duff
On Thu, May 12, 2005 at 08:10:42PM -0700, Larry Wall wrote: On Thu, May 12, 2005 at 02:55:36PM -0500, Patrick R. Michaud wrote: : My suggestion is that a match object in numeric context is the : same as evaluating its string value in a numeric context. If : we need a way to find out the

Re: Numification of captured match

2005-05-12 Thread Patrick R. Michaud
On Thu, May 12, 2005 at 08:10:42PM -0700, Larry Wall wrote: On Thu, May 12, 2005 at 02:55:36PM -0500, Patrick R. Michaud wrote: : On Fri, May 13, 2005 at 03:23:20AM +0800, Autrijus Tang wrote: : Is it really intended that we get into habit of writing this? : : if 'localhost:80' ~~

Re: Numification of captured match

2005-05-12 Thread Damian Conway
Patrick surmised: So I'm guessing that we're all in agreement that +$/, +$1, and +$subrule all refer to the numeric value of the string matched, as opposed to what's currently written about their values in the draft...? Yes. The semantics proposed in the draft have proved to be too orthogonal