perl6-docs icon indicating copy to clipboard operation
perl6-docs copied to clipboard

Regex :sigspace modifier example causes error

Open 7stud opened this issue 8 years ago • 0 comments

In Introduction to Perl 6 Regex, in the section titled modifiers, the example using the :sigspace modifier causes an error. The text says:

This is so useful that Perl provides a nice short-cut for it.

/\s*One\s+small\s+step\s*/      # yuck
m:sigspace/One small step/      # much better
mm/One small step/              # even better!

However, the last line causes an error when I try it:

~/p6_programs$ perl6 -v
This is Rakudo version 2016.11 built on MoarVM version 2016.11
implementing Perl 6.c.

~/p6_programs$ cat 4.pl
# vim: filetype=perl6

$_ = "One    small  step";
mm/One small step/;             # even better!
say $/;

~/p6_programs$ perl6 4.pl
===SORRY!=== Error while compiling /Users/7stud/p6_programs/4.pl
Missing required term after infix
at /Users/7stud/p6_programs/4.pl:4
------> mm/One small step/⏏;             # even better!
    expecting any of:
        prefix
        term

Using the modifier :s works as described:

~/p6_programs$ cat 4.pl
# vim: filetype=perl6

$_ = "One    small  step";
m:s/One small step/;             # even better!
say $/;

~/p6_programs$ perl6 4.pl
「One    small  step」

7stud avatar Jan 07 '17 10:01 7stud