On 2019-11-22 21:52, ToddAndMargo via perl6-users 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
This works:
loop (my $I=0; $I < @Result.elems; $I+=2) { say "@Result[$I]"; }
What am I doing wrong, this time?