>> On Nov 14, 2020, at 14:12, ToddAndMargo via perl6-users
<perl6-us...@perl.org> wrote:
>>
>> On 2020-11-14 11:08, Curt Tilmes wrote:
>>> On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users
>>> <perl6-us...@perl.org> wrote:
>>>> Just out of curiosity, why is the \n printed out literally here?
>>>> p6 'my @x = <"aaa\n","bbb\n","ccc\n">; for @x {print @_};'
>>> Your 'word quoting' <> is sort of like single quotes -- it keeps the
>>> literal stuff. You could
>>> use <<>> which is more like double quotes,
>>> Curt
>>
>> or remove the commas. I put everything in [0]
>>
>>
>> $ p6 'my @x = <aaa\n bbb\n ccc\n>; for @x {print "$_\n";}'
>> aaa\n
>> bbb\n
>> ccc\n
>>
>> $ p6 'my @x = <<aaa\n bbb\n ccc\n>>; for @x {print "$_\n";}'
>> aaa
>> bbb
>> ccc
>>
>> $ p6 'my @x = <<aaa\n bbb\n ccc\n>>; for @x {print "$_";}'
>> aaabbbccc
>>
>> What am I missing?
>>
>> -T
On 2020-11-14 11:18, Matthew Stuckwisch wrote:
The <…> and «…» constructors break on whitespace.
So <a,b,c,d,e,f> will actually produce the following array:
["a,b,c,d,e,f"]
It's only one item. If we placed space after the comma, that is, <a, b, c, d, e,
f>, you'd get a six item list, but with the commas attached to all but the final:
["a,", "b,", "c,", "d,", "e,", "f"]
By replacing the commas with spaces, e.g., <a b c d e f>, you allow it to break into ["a", "b", "c",
"d", "e", "f"]
Matéu
Ya, I caught that booboo. :'(
Question still stands. Why is the \n working as a CR/LF and
being printed as a litteral?