More literal transcription of your original code is to allow
zero-length match, which maintains "pos", and then checking the match
length.

#!/usr/bin/env perl6
use v6.c;

given "      foo bar" {
    die unless m/^\s+/;
    die unless m:p/ foo\s+ /;
    die if m:p/[ willnotmatch ]?/ && $/.chars;
    die unless m:p/ bar /;
}
say $/.pos; # yields "13"





-y

Reply via email to