Author: autrijus Date: Sat Feb 25 01:59:19 2006 New Revision: 7867 Modified: doc/trunk/design/syn/S05.pod
Log: * S05: Fix the <(...)> typo (was spelled <(...\>) and make the moose example slightly more idiomatic. Modified: doc/trunk/design/syn/S05.pod ============================================================================== --- doc/trunk/design/syn/S05.pod (original) +++ doc/trunk/design/syn/S05.pod Sat Feb 25 01:59:19 2006 @@ -1115,17 +1115,17 @@ my $moose = m:{ <antler> <body> - { return Moose.new( body => $<body>.attach(:$<antler>) ) } + { return Moose.new( body => $<body>().attach($<antler>()) ) } # match succeeds -- ignore the rest of the rule }.(); C<$()> is a shorthand for C<$/.()> or C<$/()>. The result object -may contain any object, not just a string. +may be of any type, not just a string. You may also capture a subset of the match as the result object using the C<< <(...)> construct: - "foo123bar" ~~ / foo <( \d+ \> bar / + "foo123bar" ~~ / foo <( \d+ )> bar / say $(); # says 123 In this case the result object is always a string when doing string