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 looks... weird. :) > > And it would have to be > > if 'localhost:80' ~~ /^(.+)\:(\d+)$/ { > my $socket = connect(~$0, ~$1); > } > > because +$1 still evaluates to 1.
That's some subtle evil. > My suggestion is that a match object in numeric context is the > same as evaluating its string value in a numeric context. While I agree that this would be the right behavior it still feels special-casey, hackish and wrong. If, as an optimization, you could tell PGE that you didn't need Match objects and only cared about the string results of your captures, that might be better. For instance, if 'localhost:80' ~~ m:s/^(.+)\:(\d+)$/ { my $socket = connect($0, $1); } :s for :string (assuming that hasn't already been taken) > If > we need a way to find out the number of match repetitions (what > the numeric context was intended to provide), it might be better > done with an explicit C<.matchcount> method or something like that. Surely that would just be [EMAIL PROTECTED] Or have I crossed the perl[56] streams again? -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]