Changeset 22445 for docs

Show
Ignore:
Timestamp:
09/28/08 23:00:50 (2 months ago)
Author:
moritz
Message:

[docs/tutorial] book update
Including, but not limited to:

  • optional params now have the ? after the name
  • capture interpolation is done with prefix:<|> (used to be prefix:<*>)
  • Chapter 7 is vastly out of date. Updated to use "regex" instead of "rule" (but got only half way), updated much other stuff, added a huge TODO list
Location:
docs/tutorial
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • docs/tutorial/ch04_basic_syntax.pod

    r22436 r22445  
    466466a boolean context, no matter what the actual value is. This particular 
    467467property means the Perl 6 C<run> call can be checked with a simple 
    468 conditional. It still returns the same numeric values it always has (0 
    469 on success and a numeric error code on failure), but it flags the 
    470 value with a property as true when the call succeeds and false when it 
    471 fails. 
     468conditional. It still returns the same numeric values as its Perl 5 
     469equivalent C<system> did (0 on success and a numeric error code on failure), 
     470but it flags the value with a property as true when the call succeeds and 
     471false when it fails. 
    472472 
    473473Properties and traits can also store a value. Both C<constant> and 
  • docs/tutorial/ch05_subroutines.pod

    r22302 r22445  
    3030Blocks of reusable code can also be called the "methods" of a particular 
    3131class of object. Methods have a few significant differences from 
    32 subroutines, a few significant differences from those found in Perl 5. 
     32subroutines, and a few significant differences from those found in Perl 5. 
    3333For instance, in Perl 6 they're distinguished by a separate keyword, 
    3434C<method>. Because of these differences, they'll be discussed in 
     
    7373X<subroutines;parameters> 
    7474One of the most significant additions to subroutines in Perl 6 is 
    75 named formal parameters. The parameter list, often called the 
     75formal parameters. The parameter list, often called the 
    7676I<signature> of the subroutine, is part of the subroutine declaration: 
    7777 
     
    135135for the average programmer, Perl 6 also allows optional parameters. 
    136136Optional parameters can be included or ignored without causing any 
    137 errors. Each optional parameter is marked with a C<?> before the 
     137errors. Each optional parameter is marked with a C<?> after the 
    138138parameter name: 
    139139 
    140   sub someopt ($required1, $required2, ?$optional1, ?$optional2) { 
     140  sub someopt ($required1, $required2, $optional1?, $optional2?) { 
    141141      ... 
    142142  } 
     
    243243  sub transport (:$planet, *%flags) {...} 
    244244 
    245   transport('name'    => 'Arthur', 
    246             'luggage' => 'lost', 
    247             'planet'  => 'Magrathea', 
    248             'towel'   => 'required'); 
     245  transport(:name('Arthur'), 
     246            :luggage('lost'), 
     247            :planet('Magrathea'), 
     248            :towel('required')); 
    249249 
    250250When they're combined with other kinds of parameters, variadic 
     
    268268optional, named, or variadic parameters: 
    269269 
    270   sub typedparams (Int $first, Str ?$second) {...} 
     270  sub typedparams (Int $first, Str $second?) {...} 
    271271 
    272272The parameter type declares the type of argument that can be bound to 
     
    322322if the call doesn't pass an argument for that parameter. 
    323323 
    324   sub default_vals ($required, ?$optional = 5) {...} 
     324  sub default_vals ($required, $optional? = 5) {...} 
    325325 
    326326Default values are only used with optional parameters. This should make 
     
    410410optional parameters: 
    411411 
    412   sub namedparams ($first, ?$second, ?$third is rw) {...} 
     412  sub namedparams ($first, $second?, $third? is rw) {...} 
    413413   
    414414  namedparams(third => 'Trillian', first => $name); 
     
    426426To get the Perl 5-style behavior where the elements of an array (or 
    427427the pairs of a hash) flatten out into the parameter list, use the 
    428 flattening operator C<*> in the call to the subroutine. Here, 
     428flattening operator C<|> in the call to the subroutine. Here, 
    429429C<$first> binds to C<@array[0]> and C<$second> binds to C<@array[1]>: 
    430430 
    431431  sub flat ($first, $second) {...} 
    432432   
    433   flat(*@array); 
     433  flat(|@array); 
    434434 
    435435A flattened hash argument acts as a list of pairs, which are bound to 
     
    438438C<%hash{'second'}>: 
    439439 
    440   sub flat_hash ($first, $second) {...} 
     440  sub flat_hash (:$first, :$second) {...} 
    441441 
    442442 
    443443  %hash = (first => 1, second => 2); 
    444   flat_hash(*%hash); 
     444  flat_hash(|%hash); 
    445445 
    446446Flattened hash arguments are useful for building up hashes of named 
     
    489489array: 
    490490 
    491   sub mixed ($req, ?$opt, ?$another, *@slurpy) {...} 
     491  sub mixed ($req, $opt?, $another?, *@slurpy) {...} 
    492492 
    493493  mixed('a', 'opt' => 1, 'b', 'c', 'd', 'e'); 
     
    511511array with or without any named arguments in the call: 
    512512 
    513   sub mixed ($req, +$opt, +$another, *@slurpy) {...} 
     513  sub mixed ($req, $opt?, $another?, *@slurpy) {...} 
    514514 
    515515  mixed('a', 'opt' => 1, 'b', 'c', 'd', 'e'); 
     
    524524X<subroutines;stub> 
    525525To declare a subroutine without defining it you give it a body 
    526 consisting of nothing but the C<...> (or "yada, yada, yada") operator. 
     526consisting of nothing but the C<...> (or "yada, yada, yada") operator, 
     527optionally followed by a message. 
    527528So, all the preceding examples that look like pseudocode with C<{...}> 
    528529for their body are actually valid subroutine declarations. 
    529530 
    530   sub stubbly (Str $name, Int ?$days) {...} 
     531  sub stubbly (Str $name, Int $days?) {...} 
     532 
     533You can include a message that appears in the error message if you try to 
     534execute a stu subroutine. 
     535 
     536  sub stubbly (Str $name, Int $days?) { ... "Don't call me" } 
    531537 
    532538When you later define the subroutine, the signature and defined traits 
    533539must exactly match the declaration. 
    534540 
    535   sub stubbly (Str $name, Int ?$days) { 
     541  sub stubbly (Str $name, Int $days?) { 
    536542      print "$name hasn't shaved in $days day"; 
    537543      print "s" if $days > 1; 
     
    651657subroutine. 
    652658 
    653   $make_tea = sub ($tealeaves, ?$sugar, ?$milk) {...} 
    654  
    655 The arrow operator used with C<for> and C<given> is just another way 
    656 of defining anonymous subroutines. The arrow doesn't require 
     659  $make_tea = sub ($tealeaves, :$sugar, :$milk) {...} 
     660 
     661The arrow operator used with C<for> and C<given> is just a way 
     662of defining anonymous blocks. The arrow doesn't require 
    657663parentheses around its parameter list. It can't declare named subs, 
    658664and can't declare a return type. 
    659665 
    660   $make_tea = -> $tealeaves, ?$sugar, ?$milk {...} 
     666  $make_tea = -> $tealeaves, :$sugar, :$milk {...} 
    661667 
    662668X<blocks;bare> 
     
    672678 
    673679 
    674 You can't use the C<return> statement within an arrow sub or bare 
    675 block sub to return from an anonymous sub. Blocks and arrow subs are 
     680You can't use the C<return> statement within an arrow block or bare 
     681block sub to return from that block. Blocks and arrow subs are 
    676682commonly used for ordinary control flow, so C<return> ignores them and 
    677683only returns from subroutines defined with C<sub> keyword or 
    678684methods. 
     685 
     686Instead you can C<leave> a block: 
     687 
     688  my $make_tea { 
     689      leave unless teamtime(); 
     690      my $tea = boil 'tealeaves'; 
     691      combine $tea, 'sugar', 'milk'; 
     692  } 
     693 
     694The simple rule is that everything declared with a C<sub> or C<method> 
     695keyword use the C<return> statement, blocks declared without such a keyword 
     696can use C<leave>. 
    679697 
    680698=head1 Multi Subroutines 
     
    711729This version of C<add> will dispatch based on the types of the first 
    712730two arguments passed in, and ignore the type of the third. 
     731 
     732Multisubs can also differ in the number of arguments as long as no 
     733ambiguities arise. 
    713734 
    714735=head1 Curried Subroutines 
  • docs/tutorial/ch07_grammars.pod

    r22304 r22445  
    33=pod 
    44 
    5 =head0 Grammars and Rules 
     5=head0 Grammars and Regexes 
     6 
     7 
     8TODO: This chapter is outdated in some ways 
     9 
     10  * It uses the old word "rule" instead of "regex" in far too many places 
     11  * The interpolation rules are outdated 
     12  * <'...'> and <"..."> are now '...' and "..." 
     13  * some of the assertion syntax has changed, for example <foo()> means 
     14    something different now 
     15  * Modifiers: explain :sigspace and :ratchet modifiers 
     16  * Modifiers: :u1, :u2... are now :bytes, :codes, :graphemes etc. 
     17  * Other missing modifiers: :overlap, :ignoreaccent 
     18  * The match object needs explanation 
    619 
    720Z<CHP-7> 
    821 
    9 X<rules;grammars and> 
    10 X<grammars and rules> 
     22X<regexes;grammars and> 
     23X<grammars and regexes> 
    1124X<regular expressions> 
    1225Perl 6 "regular expressions" are so far beyond the formal definition 
    13 of regular expressions that we decided it was time for a more 
    14 meaningful name.N<Regular expressions describe regular languages, and 
     26of regular expressions that we don't use that name anymore, but simply 
     27stick to the abbreviation I<Regex>.N<Regular expressions describe regular 
     28languages, and 
    1529consist of three primitives and a limited set of operations (three or 
    1630so, depending on the formulation). So, even Perl 5 "regular 
    17 expressions" weren't formal regular expressions.> We now call them 
    18 "rules." Perl 6 rules bring the full power of recursive descent 
    19 parsing to the core of Perl, but are comfortably useful even if you 
     31expressions" weren't formal regular expressions.>  
     32Perl 6 regexes bring the full power of recursive descent 
     33parsingN<A computer scientist would classify the most common usage of Perl 6 
     34regexes as I<deterministic context-free languages>> to the core of Perl, but are comfortably useful even if you 
    2035don't know anything about recursive descent parsing. In the usual 
    21 case, all you'll ever need to know is that rules are X<patterns> 
     36case, all you'll ever need to know is that regexes are X<patterns> 
    2237patterns for matching text. 
    2338 
    24 =head1 Using Rules 
     39=head1 Using Regexes 
    2540 
    2641Z<CHP-7-SECT-1> 
    2742 
    28 X<rules;syntax> 
    29 Rules are a language within a language, with their own syntax and 
     43X<regexes;syntax> 
     44Regexes are a language within a language, with their own syntax and 
    3045conventions. At the highest level, though, they're just another set of 
    31 Perl constructs. So the first thing to learn about rules is the Perl 
     46Perl constructs. So the first thing to learn about regexes is the Perl 
    3247"glue" code for creating and using them. 
    3348 
     
    3651Z<CHP-7-SECT-1.1> 
    3752 
    38 The simplest way to create and use a rule is an immediate match. A rule 
     53The simplest way to create and use a regex is an immediate match. A regex 
    3954defined with the C<m//>X<m// (match) operator> operator always 
    4055immediately matches.  Substitutions, defined with the C<s///> 
    4156X<s/// (substitution) operator> operator also immediately match.  A 
    42 rule defined with the C<//>X</ (slash);//;;(see m// operator)> 
     57regex defined with the C<//>X</ (slash);//;;(see m// operator)> 
    4358operator immediately matches when it's in void, boolean, string, or 
    4459numeric context, or the argument of the smart-match operator (C<~~>). 
    4560X<~ (tilde);~~ (smart match) operator> 
    4661 
    47   if $string ~~ m/\w+/      {...} 
    48   if $string ~~ s/\w+/word/ {...} 
    49   if $string ~~ /\w+/       {...} 
     62  if $string ~~ m/ \w+ /      {...} 
     63  if $string ~~ s/ \w+ /word/ {...} 
     64  if $string ~~ / \w+ /       {...} 
    5065 
    5166You can substitute other delimiters, like C<#...#>, C<[...]>, and 
     
    85100 
    86101Sometimes you want a little more flexibility than an immediate match. 
    87 The C<rx//>X<rx// (anonymous rule) operator> operator defines an 
    88 anonymous rule that can be executed later. 
     102The C<rx//>X<rx// (anonymous regex) operator> operator defines an 
     103anonymous regex that can be executed later. 
    89104 
    90105  $digits = rx/\d+/; 
    91106 
    92 The simple C<//> operator also defines an anonymous rule in all 
     107The simple C<//> operator also defines an anonymous regex in all 
    93108contexts other than void, boolean, string, or numeric, or as an 
    94109argument of C<~~>. 
    95110 
    96   $digits = /\d+/; # store rule 
     111  $digits = /\d+/; # store regex 
    97112 
    98113You can use the unary context forcing operators, C<+>, C<?>, and C<~>, 
     
    107122  $string = ~/^\w+/;      # match $_ and return string 
    108123 
    109 Another option for deferred matches is a C<rule> block. The C<rule> 
    110 keyword defines a named or anonymous rule, in much the same way that 
     124Another option for deferred matches is a C<regex> block. The C<regex> 
     125keyword defines a named or anonymous regex, in much the same way that 
    111126C<sub> declares a subroutine or C<method> declares a method. But the 
    112 code within the block of a C<rule> is rule syntax, not Perl syntax. 
    113  
    114   $digits = rule {\d+}; 
    115  
    116   rule digits {\d+} 
    117  
    118 To match a named or anonymous rule, call it as a subrule within 
    119 another rule. Subrules, whether they're named rules or a variable 
    120 containing an anonymous rule, are enclosed in assertion delimiters  
     127code within the block of a C<regex> is regex syntax, not Perl syntax. 
     128 
     129  $digits = regex {\d+}; 
     130 
     131  regex digits {\d+} 
     132 
     133There are two more keywords that defines regexes similarly to C<regex>, but 
     134they imply different modifiers. C<token> introduces a regex that does 
     135not backtrack,N<technically it implies the C<:ratchet> modifier> (more details 
     136on that below; for now it's enough to know that it matches simple regexes 
     137faster), and C<rule> is the same as C<token> except that whitespaces in 
     138regexes also match optional whitespaces in the string.N<it implies both the 
     139C<:ratchet> and the C<:sigspace> modifer>. 
     140 
     141To match a named or anonymous regex, call it as a subregex within 
     142another regex. Subregexes, whether they're named regexes or a variable 
     143containing an anonymous regex, are enclosed in assertion delimiters  
    121144C<< <...> >>. You can read more about assertions in A<CHP-7-SECT-2.4> 
    122145"Assertions" later in this chapter. 
     
    166189=cell C</.../> 
    167190 
    168 =cell Immediately match or define an anonymous rule, depending on the 
     191=cell Immediately match or define an anonymous regex, depending on the 
    169192context. 
    170193 
    171194=row  
    172195 
    173 =cell C<rule {...}> 
    174  
    175 =cell Define an anonymous rule. 
    176  
    177 =row  
    178  
    179 =cell C<rule name {...}> 
    180  
    181 =cell Define a named rule. 
     196=cell C<regex {...}> 
     197 
     198=cell Define an anonymous regex. 
     199 
     200=row  
     201 
     202=cell C<regex name {...}> 
     203 
     204=cell Define a named regex. 
    182205 
    183206=end table 
     
    189212X<grammars> 
    190213 
    191 A grammar is a collection of rules, in much the same way that a class is 
     214A grammar is a collection of regexes, in much the same way that a class is 
    192215a collection of methods. In fact, grammars are classes, they're just 
    193 classes that inherit from the universal base class C<Rule>X<Rule class>. 
     216classes that inherit from the universal base class C<Regex>X<Regex class>. 
    194217This means that grammars can inherit from other grammars, and that they 
    195 define a namespace for their rules. 
     218define a namespace for their regexes. 
    196219 
    197220  grammar Hitchhikers { 
    198       rule name {Zaphod|Ford|Arthur} 
     221      token name { Zaphod | Ford | Arthur } 
    199222   
    200       rule id   {\d+} 
     223      token id   { \d+ } 
    201224 
    202225      ... 
    203226  } 
    204227 
    205 Any rule in the current grammar or in one of its parents can be called 
    206 directly, but a rule from an external grammar needs to have its package 
     228Any regex in the current grammar or in one of its parents can be called 
     229directly, but a regex from an external grammar needs to have its package 
    207230specified: 
    208231 
    209   if $newsrelease ~~ /E<lt>Hitchhikers.nameE<gt>/ { 
     232  if $newsrelease ~~ / E<lt>Hitchhikers.nameE<gt> / { 
    210233      send_alert($1); 
    211234  } 
    212235 
    213 If you want to match against the entire grammar, you can define a rule 
     236If you want to match against the entire grammar, you can define a regex 
    214237C<TOP> in that grammar. 
    215238 
    216239  grammar Hitchhikers { 
    217       rule TOP { <name> <id> } 
     240      regex TOP { <name> <id> } 
    218241      ... 
    219242  } 
     
    235258 
    236259Every language has a set of basic components (words or parts of words) 
    237 and a set of syntax rules for combining them. The "words" in rules are 
     260and a set of syntax rules for combining them. The "words" in regexes are 
    238261literal characters (or symbols), some X<metacharacters> metacharacters 
    239 (or metasymbols),  and X<rules;escape sequences>X<escape sequences, 
    240 rules> escape sequences, while the combining syntax includes other 
    241 metacharacters, X<quantifiers, rules> X<rules;quantifiers> quantifiers, 
     262(or metasymbols),  and X<regexes;escape sequences>X<escape sequences, 
     263regexes> escape sequences, while the combining syntax includes other 
     264metacharacters, X<quantifiers, regexes> X<regexes;quantifiers> quantifiers, 
    242265bracketing characters, and assertions. 
    243266 
     
    250273C<.> matches any single character, even a newline character. Actually, 
    251274what it matches by default is a Unicode grapheme, but you can change 
    252 that behavior with a pragma in your code, or a modifier on the rule. 
     275that behavior with a pragma in your code, or a modifier on the regex. 
    253276We'll talk more about modifiers in A<CHP-7-SECT-2.5>"Modifiers" later 
    254277in this chapter. The C<^> and C<$> metacharacters are zero-width 
     
    264287C<#> marks a comment to the end of the line. Whitespace insensitivity 
    265288(the old C</x> modifier) is on by default, so you can start a comment at 
    266 any point on any line in a rule. Just make sure you don't comment out 
    267 the symbol that terminates the rule. The C<:=> 
    268 X<: (colon);:= (binding);in rules> binds a hypothetical variable to 
    269 the result of a subrule or grouped pattern. Hypotheticals are covered 
     289any point on any line in a regex. Just make sure you don't comment out 
     290the symbol that terminates the regex. The C<:=> 
     291X<: (colon);:= (binding);in regex> binds a hypothetical variable to 
     292the result of a subregex or grouped pattern. Hypotheticals are covered 
    270293in A<CHP-7-SECT-5>"Hypothetical Variables" later in this chapter. 
    271294 
    272295The metacharacters C<()>, C<[]>, C<{}> and C<E<lt>E<gt>> are bracketing 
    273 pairs. The pairs always have to be balanced within the rule, unless they 
     296pairs. The pairs always have to be balanced within the regex, unless they 
    274297are literal characters (escaped with a C<\>). The brackets C<()> and 
    275298C<[]> group patterns to match as a single atom. They're often used to 
     
    277300of patterns with a quantifier, among other things. Parentheses C<()> are 
    278301capturing and square brackets C<[]> are non-capturing. The C<{}> 
    279 brackets define a section of Perl code (a closure) within a rule. These 
     302brackets define a section of Perl code (a closure) within a regex. These 
    280303closures are always a successful zero-width match, unless the code 
    281304explicitly calls the C<fail> function. The C<E<lt>...E<gt>> brackets 
     
    305328 
    306329=cell Match any single character, including a newline. 
    307 X<. (dot);. match single character (rules)> 
     330X<. (dot);. match single character (regexes)> 
    308331 
    309332=row  
     
    312335 
    313336=cell Match the beginning of a string. 
    314 X<^ (caret);^ beginning of string (rules)> 
     337X<^ (caret);^ beginning of string (regexes)> 
    315338 
    316339=row  
     
    319342 
    320343=cell Match the end of a string. 
    321 X<$ (dollar sign);$ end of string (rules)> 
     344X<$ (dollar sign);$ end of string (regexes)> 
    322345 
    323346=row  
     
    326349 
    327350=cell Match the beginning of a line. 
    328 X<^ (caret);^^ beginning of line (rules)> 
     351X<^ (caret);^^ beginning of line (regexes)> 
    329352 
    330353=row  
     
    333356 
    334357=cell Match the end of a line. 
    335 X<$ (dollar sign);$$ end of line (rules)> 
     358X<$ (dollar sign);$$ end of line (regexes)> 
    336359 
    337360=row  
     
    353376=cell Escape a metacharacter to get a literal character, or escape a 
    354377literal character to get a metacharacter. 
    355 X<\ (backslash);\ escape sequences (rules)> 
    356 X<\ (backslash);\ to escape metacharacters (rules)> 
     378X<\ (backslash);\ escape sequences (regexes)> 
     379X<\ (backslash);\ to escape metacharacters (regexes)> 
    357380 
    358381=row  
     
    367390 
    368391=cell Bind the result of a match to a hypothetical variable. 
    369 X<: (colon);:= (binding);in rules> 
     392X<: (colon);:= (binding);in regexes> 
    370393 
    371394=row  
     
    385408=cell C<{...}> 
    386409 
    387 =cell Execute a closure (Perl 6 code) within a rule. 
     410=cell Execute a closure (Perl 6 code) within a regex. 
    388411 
    389412=row  
     
    400423Z<CHP-7-SECT-2.2> 
    401424 
    402 X<escape sequences, rules> 
    403 X<rules;escape sequences> 
    404 X<\ (backslash);\ escape sequences (rules)> 
     425X<escape sequences, regexes> 
     426X<regexes;escape sequences> 
     427X<\ (backslash);\ escape sequences (regexes)> 
    405428The escape sequences are literal characters acting as metacharacters, 
    406429marked with the C<\> escape. Some escape sequences represent single 
     
    412435brackets, C<()>, C<{}>, and C<E<lt>E<gt>> work in place of C<[]>.  
    413436 
    414 X<variable interpolation in rules> 
    415 X<rules;variable interpolation> 
     437X<variable interpolation in regexes> 
     438X<regexes;variable interpolation> 
    416439Note that since an ordinary variable now interpolates as a literal 
    417 string by default, the C<\Q> escape sequence is rarely needed. 
    418  
    419 A<CHP-7-TABLE-3>Table 7-3 shows the escape sequences for rules.  
     440string by default, the C<\Q> escape is rarely needed. 
     441 
     442A<CHP-7-TABLE-3>Table 7-3 shows the escape sequences for regexes.  
    420443 
    421444=begin table picture Escape sequences 
     
    625648match. 
    626649 
    627 X<. (dot);.. (range);quantifier (rules)> 
    628 X<. (dot);... (infinite range);quantifier (rules)> 
    629 The numeric quantifiers use assertion syntax. A single number 
    630 (C<E<lt>3E<gt>>) requires exactly that many matches. A numeric range 
    631 quantifier (C<E<lt>3C<..>5E<gt>>) succeeds if the number of matches is 
    632 between the minimum and maximum numbers. A range with three trailing 
    633 dots (C<E<lt>2...E<gt>>) is shorthand for C<E<lt>R<n>..InfE<gt>> and 
    634 matches as many times as possible. 
     650X<. (dot);.. (range);quantifier (regexes)> 
     651X<. (dot);... (infinite range);quantifier (regexes)> 
     652The numeric quantifiers use the C<**> operator followed by the number of 
     653desired matches. For a range of matches you can use a closure that returns 
     654a range (C<a**{2..4}> matches two to four C<a>'s, (C<a**{2..Inf}>) two or 
     655more C<a>'s). 
    635656 
    636657Each quantifier has a minimal alternate form, marked with a trailing 
     
    683704=row  
    684705 
    685 =cell C<E<lt>>R<n>C<E<gt>> 
    686  
    687 =cell C<E<lt>>R<n>C<E<gt>?> 
     706=cell C**n> 
     707 
     708=cell C<**?n> 
    688709 
    689710=cell Match exactly R<n> times. 
     
    691712=row  
    692713 
    693 =cell C<E<lt>>R<n>C<..>R<m>C<E<gt>> 
    694  
    695 =cell C<E<lt>>R<n>C<..>R<m>C<E<gt>?> 
     714=cell C<**{n..m}> 
     715=cell C<**?{n..m}> 
    696716 
    697717=cell Match at least R<n> and no more than R<m> times. 
     
    712732Z<CHP-7-SECT-2.4> 
    713733 
    714 X<assertions, rules> 
    715 X<rules;assertions> 
     734X<assertions, regexes> 
     735X<regexes;assertions> 
    716736In general, an assertion simply states that some condition or state is 
    717737true and the match fails when that assertion is false. Many different 
    718738constructs with many different purposes use assertion syntax.  
    719739 
    720 X<variable interpolation in rules> 
     740X<variable interpolation in regexes> 
    721741X<rules;variable interpolation> 
    722 Assertions match named and anonymous rules, arrays or hashes containing 
    723 anonymous rules, and subroutines or closures that return anonymous 
    724 rules. You have to enclose a variable in assertion delimiters to get it 
     742Assertions match named and anonymous regexes, arrays or hashes containing 
     743anonymous regexes, and subroutines or closures that return anonymous 
     744regexes. You have to enclose a variable in assertion delimiters to get it 
    725745to interpolate as an anonymous rule or rules. A bare scalar in a pattern 
    726746interpolates as a literal string, while a scalar variable in assertion 
     
    977997=row  
    978998 
    979 =cell C<:W> 
    980  
    981 =cell  
    982  
    983 =cell Turn off intelligent whitespace matching (return to default). 
    984  
    985 =row  
    986  
    987999=cell  
    9881000 
     
    10591071=row  
    10601072 
    1061 =cell  
    1062  
    1063 =cell C<:p5> 
     1073=cell C<:P5> 
     1074 
     1075=cell C<:Perl5> 
    10641076 
    10651077=cell The pattern uses Perl 5 regex syntax. 
     
    12421254Hypothetical variables are a powerful way of building up data structures 
    12431255from within a match. Ordinary captures with C<()> store the result of 
    1244 the captures in C<$1>, C<$2>, etc. The values stored in these variables 
     1256the captures in C<$0>, C<$1>, etc. The values stored in these variables 
    1245125