On Tue, Jul 19, 2011 at 03:16:49PM -0700, Carl Mäsak wrote: > <masak> rakudo: my @a = "OH HAI"; say so "OH HAI" ~~ /<@a>/ > <p6eval> rakudo f63b82: OUTPUT«Bool::False» > <masak> I think this is wrong. > * masak submits rakudobug > <masak> "The default way in which the engine handles a string scalar > is to match it as a C<< '...' >> literal (i.e. it does not treat the > interpolated string as a subpattern)." > <masak> (from S05) > <masak> rakudo: my @a = "OH\\sHAI"; say so "OH HAI" ~~ /<@a>/ > <p6eval> rakudo f63b82: OUTPUT«Bool::True» > <masak> uurgh. > <masak> rakudo: my $x = "OH\\sHAI"; say so "OH HAI" ~~ /<$x>/ > <p6eval> rakudo f63b82: OUTPUT«Bool::True» > <masak> oh! it occurs for scalars as well.
Bare variables are treated as string literals; variables in assertions (angle brackets) are interpolated as regexes. Also from S05: "A leading C<$> indicates an indirect subrule call. The variable must contain either a C<Regex> object (really an anonymous method--see above), or a string to be compiled as the regex. The string is never matched literally." "A leading C<@> matches like a bare array except that each element is treated as a subrule (string or C<Regex> object) rather than as a literal. That is, a string is forced to be compiled as a subrule instead of being matched literally. (There is no difference for a C<Regex> object.)" Thus if $a is a string value, then / $a / matches $a literally, while / <$a> / interpolates the string as a regex and performs the match. Pm