Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Document order of operations in qqw and qqww
  • Loading branch information
skids committed Jul 8, 2016
1 parent fe89ae2 commit d1ed93b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/Language/quoting.pod6
Expand Up @@ -165,6 +165,12 @@ you need to use the C<qqw> variant:
my @list = qqw{$a b c};
say @list; # 42 b c
Note that variable interpolation happens before word splitting:
my $a = "a b";
my @list = qqw{$a c};
.say for @list; # says "a", says "b", then says "c"
=head2 X<<<Word quoting with interpolation and quote protection: qqww|quote,qqww;quote,<< >>;quote,« »>>>
The C<qqw> form of word quoting will treat quote characters literally, leaving them in the
Expand All @@ -182,6 +188,14 @@ or equivalently:
my $a = 42; say <<"$a b" c>>.perl; # ("42 b", "c")
my $a = 42; say «"$a b" c».perl; # ("42 b", "c")
Quote protection happens before interpolation, and interpolation happens before word splitting,
so quotes coming from inside interpolated variables are just literal quote characters:
my $a = "1 2";
say qqww{"$a" $a}.perl; # ("1 2", "1", "2")
my $b = "1 \"2 3\"";
say qqww{"$b" $b}.perl; # ("1 \"2 3\"", "1", "\"2", "3\"")
=head2 X<Shell quoting: qx|quote,qx>
To run a string as an external program, not only is it possible to pass the
Expand Down

0 comments on commit d1ed93b

Please sign in to comment.