Jonathan Scott Duff skribis 2004-09-17 9:57 (-0500):
> [foo]~5 # match exactly 5 times
> [foo]~{0...} # verbose [foo]*
> [foo]~{1...} # verbose [foo]+
> [foo]~{1..5} # match from 1 to 5 times
> [foo]~{[1,3,5]} # match exactly 1, 3, or 5 times
> [EMAIL PROTECTED] # treat each element of @foo as a
> # number and only match that
> # many times. (same as previous
> # basically)
> [foo]~{&foo} # match based on the return value of &foo
> [foo]~{%foo} # ???
> And surely these can be made to work:
> [foo]~[0...] # [foo]:[0...]
> [foo]~[1,3,5] # [foo]:[1,3,5]
> [EMAIL PROTECTED] # [foo]:@foo
Easier:
Variable Literal
\d~$foo \d~5, \d~1..5 # Range object or integer.
[EMAIL PROTECTED] \d~[...] # \d~any(...)
\d~&foo \d~{...} # Depending on what the closure returns.
Obviously, $foo can also be an arrayref or coderef.
I think whitespace around the ~ can be made valid without making
anything ambiguous. The expression at its right side should not have
whitespace in it. If it does have whitespace, [] or {} is needed to
disambiguate.
Juerd