我写了一个测试程序,现在似乎如果我不使用$/方法签名因为我必须在方法中使用.match,我就不能再做任何事了.我做错了什么?
另一个问题是,如果是.match集合$/,并且$/是只读的,那么我不能$/在包含.match语句的方法的签名中,并且我不能.match在方法内部有多个,因为每个都.match将尝试设置只读$/.这对编程来说非常尴尬.
这是测试程序,.match里面只有一个语句和结果:
grammar test {
regex TOP { <foo><bar> }
regex foo { :i \s* foo \s* }
regex bar { :i \s bar \s* }
}
class actTest {
method foo ($x) { # program fails if I use $/ in signature
print "1 "; say $x; # how to combine the 2 and show $x as …Run Code Online (Sandbox Code Playgroud)