develooper Front page | perl.perl6.language | Postings from May 2005

Re: C<::> in rules

Thread Previous | Thread Next
From:
Aaron Sherman
Date:
May 12, 2005 14:16
Subject:
Re: C<::> in rules
Message ID:
1115932554.27930.531.camel@pps
On Thu, 2005-05-12 at 15:41, Patrick R. Michaud wrote:
>     $rule = rx :w / plane ::: (\d+) | train ::: (\w+) | auto ::: (\S+) / ;
>     $rule = rx :w /[ plane :: (\d+) | train :: (\w+) | auto :: (\S+) ]/ ;
> 
> On Thu, May 12, 2005 at 02:29:24PM -0400, Aaron Sherman wrote:
> > On Thu, 2005-05-12 at 13:44, Patrick R. Michaud wrote:

> > > False.  In the first case the group is the whole rule.  In the second
> > > case the group would not include the (implied) '.*?' at the start of
> > > the rule.

This was a very unfortunate choice of explanations, since an implied
".*?" would change the semantics of the match deeply. However, your
later explanation:

>     $r1 = rx /[abc :: def | ghi :: jkl | mn :: op]/;
> 
>     "abcdef"  ~~ $r1         # matches "abcdef"
>     "xyzghijkl" ~~ $r1       # matches "ghijkl"
>     "xyzabcghijkl" ~~ $r1    # matches "ghijkl"
> 
> Why does the last one match?  Because it fails the group but
> doesn't fail the rule -- i.e., the rule is still free to advance
> its initial pointer to the next character and try again. 

... is very understandable. Now I'm just left with a vague sense that I
never want to see anyone use :: :-)

-- 
Aaron Sherman <ajs@ajs.com>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About