Hello,

What is the function of the 'lines' method call (in @Result.lines.kv) in
your for loop?

If you remove it, does it 'just do what you want'?

I ask this because of the following interaction on the REPL:

> my @x = (1, 2, 3, 4, 5, 6, 7, 8);
[1 2 3 4 5 6 7 8]

> @x.kv
(0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8)

> @x.lines
(1 2 3 4 5 6 7 8)

> @x.lines.kv
(0 1 2 3 4 5 6 7 8)

> @x.lines.kv[0]
0

> @x.lines.kv[1]
1 2 3 4 5 6 7 8

> @x.lines.kv[2]
Nil

Regards,

Raymond.

On Sat, 23 Nov 2019 at 06:52, ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> C:\NtUtil>C:\rakudo\bin\perl6.bat -v
> This is Rakudo Star version 2019.03.1 built on MoarVM version 2019.03
> implementing Perl 6.d.
>
> Windows 7 SP1, x64
>
>
> I am trying to write a simple loop in Windows and I
> am doing something wrong.
>
> @Result definitely have something in it.
>
> This what the data looks like outside of perl:
>
> C:\NtUtil>wmic.exe volume get deviceid,label,name
> DeviceID                                           Label             Name
>
> \\?\Volume{c9b182e9-96a0-11e2-9a72-806e6f6e6963}\  System Reserved
> \\?\Volume{
> c9b182e9-96a0-11e2-9a72-806e6f6e6963}\
> \\?\Volume{e20f10e6-6b04-4748-b7b8-2704997af1f1}\  KVM-W7-Backup     M:\
>
> \\?\Volume{c9b182ea-96a0-11e2-9a72-806e6f6e6963}\  DRIVE_C           C:\
>
> \\?\Volume{5efeb388-02e8-11e8-9297-806e6f6e6963}\                    D:\
>
> \\?\Volume{4084e22f-03c2-11e9-bb20-806e6f6e6963}\  virtio-win-0.1.1  E:\
>
>
> This is my code.
>
> <UUID.pl6>
>
>
> my @Result;
>
> @Result = qx ( wmic.exe volume get deviceid,label,name ).lines;
> say @Result[0];
> say @Result[2];
> say @Result[4];
> say @Result[6];
> say @Result[8];
>
>
> say "for @Result loop";
> for @Result.lines.kv -> $I, $Line {
>     say $I;
>     # if  $Line.words[2] = "BACKUP" { say $Line.words[1]; }
>     # say $Line.words[1];
>     # say $Line.words[2];
>     # say $Line.words[3];
>     # say "";
> }
> </UUID/pl6>
>
> This is the result:
>
> C:\NtUtil>C:\rakudo\bin\perl6.bat UUID.pl6
> DeviceID                                           Label             Name
>
> \\?\Volume{c9b182e9-96a0-11e2-9a72-806e6f6e6963}\  System Reserved
> \\?\Volume{
> c9b182e9-96a0-11e2-9a72-806e6f6e6963}\
> \\?\Volume{e20f10e6-6b04-4748-b7b8-2704997af1f1}\  KVM-W7-Backup     M:\
>
> \\?\Volume{c9b182ea-96a0-11e2-9a72-806e6f6e6963}\  DRIVE_C           C:\
>
> \\?\Volume{5efeb388-02e8-11e8-9297-806e6f6e6963}\                    D:\
>
> for @Result loop
> 0
>
>
> Why is the loop stopping at @Result[0] ?
>
> Confused,
> -T
>

Reply via email to