split to walk into an HoH ?
hello people, removing shell scripts is a good way to learn raku and compare. today i want to replace this: fix () { awk -F, '{print $1" "$2}' | sort -u | awk -F" " '{ if (seen == $1) print "\t"$2; else { seen = $1; print $1 } }' } and i got this: fix () perl6 -e ' my %section; lines.map: { my ($s,$ss) = .split(","); %section{$s;$ss} = 1; } %section.keys.map: { .say for $_ , |%section{$_}.keys.map: {"\t$_"} } ' ";" to walk in the hoh is really awesome but i don't know even know from where i know it and what's the object underneath. it isn't listed in the list of operators (https://docs.perl6.org/language/operators). i would like to know because it would be nice to make this block my ($s,$ss) = .split(","); %section{$s;$ss} = 1; a one liner so i'm searching for something like %section{ .split(",").walkTheHash } = 1; any help will be warmly welcome. regards marc
Re: split to walk into an HoH ?
Could you post some input and expected output? That would make it easier for me (and perhaps others) to see what exactly you're trying to accomplish, in practical terms. On Fri, 22 Nov 2019 14:39:33 +0100 Marc Chantreux wrote: > hello people, > > removing shell scripts is a good way to learn raku and compare. > today i want to replace this: > > fix () { > awk -F, '{print $1" "$2}' | > sort -u | > awk -F" " '{ > if (seen == $1) print "\t"$2; > else { seen = $1; print $1 } > }' > } > > and i got this: > > fix () perl6 -e ' > my %section; > lines.map: { > my ($s,$ss) = .split(","); > %section{$s;$ss} = 1; > } > %section.keys.map: > { .say for $_ , |%section{$_}.keys.map: {"\t$_"} } > ' > > ";" to walk in the hoh is really awesome but i don't know even know > from where i know it and what's the object underneath. > it isn't listed in the list of operators > (https://docs.perl6.org/language/operators). > > i would like to know because it would be nice to make this block > > my ($s,$ss) = .split(","); > %section{$s;$ss} = 1; > > a one liner so i'm searching for something like > > %section{ .split(",").walkTheHash } = 1; > > any help will be warmly welcome. > > regards > marc -- With kind regards, Patrick Spek www: https://www.tyil.nl/ mail: p.s...@tyil.nl pgp: 1660 F6A2 DFA7 5347 322A 4DC0 7A6A C285 E2D9 8827 social: https://soc.fglt.nl/tyil git:https://gitlab.com/tyil/ pgpCNSMENxBRN.pgp Description: OpenPGP digital signature
Re: split to walk into an HoH ?
On 2019-11-22 Marc Chantreux wrote: > ";" to walk in the hoh is really awesome but i don't know even know > from where i know it and what's the object underneath. > it isn't listed in the list of operators It's mentioned in the page about subscripts: https://docs.perl6.org/language/subscripts#Multiple_dimensions (it's not easy to find, though, unless you know already that it's there) The method seems to be:: multi sub postcircumfix:<[; ]>(\SELF, @indices) and its adverbial variants. This works:: my %section = ( a => %( b => %( c => 1 ) ) ); my @path = «a b c»; say postcircumfix:<{; }>(%section,@path); and prints ``(1)`` (the return value is a list) From a quick look through ``Perl6/Grammar.nqp`` and ``Perl6/Actions.nqp``, I think that the semicolon is special-cased by the compiler, so the slightly ugly way above (call the operator directly) is probably the only way that works. -- Dakkar - GPG public key fingerprint = A071 E618 DD2C 5901 9574 6FE2 40EA 9883 7519 3F88 key id = 0x75193F88
Fwd: split to walk into an HoH ?
Hi Marc, I did a search for 'semicolon' on the following page and found the interesting text below. Semicolons are used to create multidimensional lists, maybe that's what's going on in your code? https://docs.perl6.org/language/list "Lists of Lists can also be created by combining comma and semicolon. This is also called multi-dimensional syntax, because it is most often used to index multidimensional arrays." "Unlike a comma, a hanging semicolon does not create a multidimensional list in a literal. However, be aware that this behavior changes in most argument lists, where the exact behavior depends on the function... ." "Because the semicolon doubles as a statement terminator it will end a literal list when used at the top level, instead creating a statement list. If you want to create a statement list inside parenthesis, use a sigil before the parenthesis... ." HTH, Bill. PS I would presume some variation of 'next' would work where you're using 'walkTheHash', but I don't really know for sure. On Fri, Nov 22, 2019 at 5:45 AM Marc Chantreux wrote: > > hello people, > > removing shell scripts is a good way to learn raku and compare. > today i want to replace this: > > fix () { > awk -F, '{print $1" "$2}' | > sort -u | > awk -F" " '{ > if (seen == $1) print "\t"$2; > else { seen = $1; print $1 } > }' > } > > and i got this: > > fix () perl6 -e ' > my %section; > lines.map: { > my ($s,$ss) = .split(","); > %section{$s;$ss} = 1; > } > %section.keys.map: > { .say for $_ , |%section{$_}.keys.map: {"\t$_"} } > ' > > ";" to walk in the hoh is really awesome but i don't know even know > from where i know it and what's the object underneath. > it isn't listed in the list of operators > (https://docs.perl6.org/language/operators). > > i would like to know because it would be nice to make this block > > my ($s,$ss) = .split(","); > %section{$s;$ss} = 1; > > a one liner so i'm searching for something like > > %section{ .split(",").walkTheHash } = 1; > > any help will be warmly welcome. > > regards > marc
Re: split to walk into an HoH ?
hello, On Fri, Nov 22, 2019 at 03:07:28PM +0100, Patrick Spek via perl6-users wrote: > Could you post some input and expected output? That would make it > easier for me (and perhaps others) to see what exactly you're trying to > accomplish, in practical terms. sorry ... i'm so confortable with awk i haven't though about some are not. i sincerely apologize. Basically i want to figure out what are the sections, subsections of of a CSV file: A,1,garbage . A,2,garbage . A,2,garbage . A,2,garbage . A,3,garbage . A,3,garbage . A,3,garbage . B,1,garbage . B,2,garbage . B,2,garbage . B,2,garbage . B,3,garbage . B,3,garbage . B,3,garbage . becomes A 1 2 3 B 1 2 3 regards, marc
Re: split to walk into an HoH ?
> From a quick look through ``Perl6/Grammar.nqp`` and > ``Perl6/Actions.nqp``, I think that the semicolon is special-cased by > the compiler, so the slightly ugly way above (call the operator > directly) is probably the only way that works. *this* is the level of expertise i miss :) thanks for your reply. marc
Re: split to walk into an HoH ?
> On Nov 22, 2019, at 9:06 AM, Marc Chantreux wrote: > > hello, > > On Fri, Nov 22, 2019 at 03:07:28PM +0100, Patrick Spek via perl6-users wrote: >> Could you post some input and expected output? That would make it >> easier for me (and perhaps others) to see what exactly you're trying to >> accomplish, in practical terms. > > sorry ... i'm so confortable with awk i haven't though about some are > not. i sincerely apologize. > > Basically i want to figure out what are the sections, subsections of of > a CSV file: > >A,1,garbage . >A,2,garbage . >A,2,garbage . >A,2,garbage . >A,3,garbage . >A,3,garbage . >A,3,garbage . >B,1,garbage . >B,2,garbage . >B,2,garbage . >B,2,garbage . >B,3,garbage . >B,3,garbage . >B,3,garbage . > > becomes > >A >1 >2 >3 >B >1 >2 >3 > > regards, > marc Marc, When I run your original Awk code against the .csv data you listed above, I get this output: A 2 3 B 2 3 The first key of each second level is missing, which differs from your sample output above. Have I corrupted your Awk code, or have I misunderstood something, or what? -- Thank you, Bruce Gray (Util of PerlMonks)
Re: split to walk into an HoH ?
Hi Marc, here's a one-liner based on the classify method, which you may find to be an interesting jumping-off-point, or centerpiece: perl6 -e 'use JSON::Fast; my %foo = lines()>>.trim-leading.classify(*.split(",").head(2)); say to-json %foo' A,1,garbage . A,2,garbage . A,2,garbage . A,2,garbage . A,3,garbage . A,3,garbage . A,3,garbage . B,1,garbage . B,2,garbage . B,2,garbage . B,2,garbage . B,3,garbage . B,3,garbage . B,3,garbage . { "A": { "3": [ "A,3,garbage .", "A,3,garbage .", "A,3,garbage ." ], "1": [ "A,1,garbage ." ], "2": [ "A,2,garbage .", "A,2,garbage .", "A,2,garbage ." ] }, "B": { "3": [ "B,3,garbage .", "B,3,garbage .", "B,3,garbage ." ], "1": [ "B,1,garbage ." ], "2": [ "B,2,garbage .", "B,2,garbage .", "B,2,garbage ." ] } } Things to note are: it makes hashes, so the order isn't retained. if that's important, you could, for example, use/build a Hash that retains its key insertion order and call .categorize-list on an instance of it. Hope that helps, and Good Luck! - Timo On 22/11/2019 16:06, Marc Chantreux wrote: > hello, > > On Fri, Nov 22, 2019 at 03:07:28PM +0100, Patrick Spek via perl6-users wrote: >> Could you post some input and expected output? That would make it >> easier for me (and perhaps others) to see what exactly you're trying to >> accomplish, in practical terms. > sorry ... i'm so confortable with awk i haven't though about some are > not. i sincerely apologize. > > Basically i want to figure out what are the sections, subsections of of > a CSV file: > > A,1,garbage . > A,2,garbage . > A,2,garbage . > A,2,garbage . > A,3,garbage . > A,3,garbage . > A,3,garbage . > B,1,garbage . > B,2,garbage . > B,2,garbage . > B,2,garbage . > B,3,garbage . > B,3,garbage . > B,3,garbage . > > becomes > > A > 1 > 2 > 3 > B > 1 > 2 > 3 > > regards, > marc
Re: Fwd: split to walk into an HoH ?
On Fri, Nov 22, 2019 at 06:20:51AM -0800, William Michels via perl6-users wrote: > Hi Marc, I did a search for 'semicolon' on the following page and > found the interesting text below. Semicolons are used to create > multidimensional lists, maybe that's what's going on in your code? indeed! i tried with ";" but it wasn't that helpful. :) > PS I would presume some variation of 'next' would work where you're > using 'walkTheHash', but I don't really know for sure. Gianni gave the solution: my script became: fix () perl6 -e ' my %section; lines.map: {postcircumfix:<{; }>( %section, .split(",") ) = 1 }; %section.keys.map: { .say for $_ , |%section{$_}.keys.map: {"\t$_"} } ' it would be nice to have a shorter syntax to access to access to postcircumfix:<{; }> but still: it's awesome. regards marc
Re: split to walk into an HoH ?
> On Nov 22, 2019, at 9:57 AM, Marc Chantreux wrote: > > On Fri, Nov 22, 2019 at 06:20:51AM -0800, William Michels via perl6-users > wrote: >> Hi Marc, I did a search for 'semicolon' on the following page and >> found the interesting text below. Semicolons are used to create >> multidimensional lists, maybe that's what's going on in your code? > > indeed! i tried with ";" but it wasn't that helpful. :) > >> PS I would presume some variation of 'next' would work where you're >> using 'walkTheHash', but I don't really know for sure. > > Gianni gave the solution: my script became: > >fix () perl6 -e ' >my %section; >lines.map: {postcircumfix:<{; }>( %section, .split(",") ) = 1 }; >%section.keys.map: { .say for $_ , |%section{$_}.keys.map: {"\t$_"} } >' > > it would be nice to have a shorter syntax to access to access to > postcircumfix:<{; }> but still: it's awesome. > > regards > > marc FWIW, I would make %section an HoA, which would be a less compact structure in memory, but allows more succinct manipulation, like so: my %section = lines() .map( *.split(",") ) .classify( { .[0] }, :as{ .[1] } ); for %section.sort { say .key; say "\t$_" for .value.sort.unique; }
Re: split to walk into an HoH ?
hello Bruce, > The first key of each second level is missing, which differs from your sample > output above. > Have I corrupted your Awk code, or have I misunderstood something, or what? you just spotted a bug: the first subkey *is* indeed required. actually fixing the bug makes the awk version even shorter. fix () { awk -F, '{print $1" "$2}' | sort -u | awk -F" " ' seen != $1 { seen = $1; print $1 } { print "\t"$2 } ' } regards marc
Re: split to walk into an HoH ?
inline: On Fri, Nov 22, 2019 at 7:20 AM Bruce Gray wrote: > > > > > On Nov 22, 2019, at 9:06 AM, Marc Chantreux wrote: > > > > hello, > > > > On Fri, Nov 22, 2019 at 03:07:28PM +0100, Patrick Spek via perl6-users > > wrote: > >> Could you post some input and expected output? That would make it > >> easier for me (and perhaps others) to see what exactly you're trying to > >> accomplish, in practical terms. > > > > sorry ... i'm so confortable with awk i haven't though about some are > > not. i sincerely apologize. > > > > Basically i want to figure out what are the sections, subsections of of > > a CSV file: > > > >A,1,garbage . > >A,2,garbage . > >A,2,garbage . > >A,2,garbage . > >A,3,garbage . > >A,3,garbage . > >A,3,garbage . > >B,1,garbage . > >B,2,garbage . > >B,2,garbage . > >B,2,garbage . > >B,3,garbage . > >B,3,garbage . > >B,3,garbage . > > > > becomes > > > >A > >1 > >2 > >3 > >B > >1 > >2 > >3 > > > > regards, > > marc > > Marc, > > When I run your original Awk code against the .csv data you listed above, I > get this output: > A > 2 > 3 > B > 2 > 3 > The first key of each second level is missing, which differs from your sample > output above. > Have I corrupted your Awk code, or have I misunderstood something, or what? > > -- > Thank you, > Bruce Gray (Util of PerlMonks) I get the same result using awk as Bruce, although I unpacked Marc's awk code into a (long) one-liner: mbook:~ homedir$ cat awk_test1.csv | awk -F, '{print $1" "$2}' | sort -u | awk -F" " '{if (seen == $1) print "\t"$2; else { seen = $1; print $1 }}' A 2 3 B 2 3 mbook:~ homedir$ HTH, Bill.
Re: split to walk into an HoH ?
hello Timo, > lines()>>.trim-leading.classify(*.split(",").head(2)); say to-json %foo' which led me to this solution: fix () perl6 -e ' lines.classify(*.split(",").head(2)).pairs.map: { .say for .key, |.value.map({ "\t" ~ .key }); } ' fix () perl6 -e ' lines\ .classify( *.split(",").head(2) ) .pairs .map: { .say for .key, |.value.map({ "\t" ~ .key }); } ' which is nice to read but hold much more data in memory. anyway: good point. regards marc
Re: split to walk into an HoH ?
> which led me to this solution: > fix () perl6 -e ' > lines.classify(*.split(",").head(2)).pairs.map: { > .say for .key, |.value.map({ "\t" ~ .key }); > } > ' Hi Marc, I tried the first solution you posted and the "subheaders" are returned out of order (e.g. "2,1,3" and not "1,2,3"): mbook:~ homedir$ cat p6_chunk_csv.p6 lines.classify(*.split(",").head(2)).pairs.map: { .say for .key, |.value.map({ "\t" ~ .key }); } mbook:~ homedir$ cat awk_test1.csv | perl6 p6_chunk_csv.p6 B 3 1 2 A 2 3 1 mbook:~ homedir$ HTH, Bill. On Fri, Nov 22, 2019 at 9:13 AM Marc Chantreux wrote: > > hello Timo, > > > lines()>>.trim-leading.classify(*.split(",").head(2)); say to-json %foo' > > which led me to this solution: > > fix () perl6 -e ' > lines.classify(*.split(",").head(2)).pairs.map: { > .say for .key, |.value.map({ "\t" ~ .key }); > } > ' > > fix () perl6 -e ' > lines\ > .classify( *.split(",").head(2) ) > .pairs > .map: { .say for .key, |.value.map({ "\t" ~ .key }); } > ' > > which is nice to read but hold much more data in memory. > anyway: good point. > > regards > marc
Re: split to walk into an HoH ?
hello, > FWIW, I would make %section an HoA, which would be a less compact > structure in memory, but allows more succinct manipulation, like so: > my %section = lines() > .map( *.split(",") ) > .classify( { .[0] }, :as{ .[1] } ); > for %section.sort { > say .key; > say "\t$_" for .value.sort.unique; > } then * no need of %section * no need to sort so it becames: fix () perl6 -e ' lines.map( *.split(",") ) .classify( { .[0] }, :as{ .[1] } ) .map: { say .key; say "\t$_" for .value.unique } ' even if the semicolon thing goes on scratching me, i'm really happy about this one! thanks a lot. regards marc
Re: split to walk into an HoH ?
hello, > Hi Marc, I tried the first solution you posted and the "subheaders" > are returned out of order (e.g. "2,1,3" and not "1,2,3"): you're right but it doesn't matter in this usecase. > mbook:~ homedir$ cat p6_chunk_csv.p6 > lines.classify(*.split(",").head(2)).pairs.map: { > .say for .key, |.value.map({ "\t" ~ .key }); > } > mbook:~ homedir$ cat awk_test1.csv | perl6 p6_chunk_csv.p6 useless use of cat: as lines() works on $*ARGFILES, you can just write: perl6 p6_chunk_csv.p6 awk_test1.csv thanks for helping me regards marc
Re: split to walk into an HoH ?
On Friday, November 22, Marc Chantreux wrote: > so it becames: > > fix () perl6 -e ' > lines.map( *.split(",") ) > .classify( { .[0] }, :as{ .[1] } ) > .map: { say .key; say "\t$_" for .value.unique } > ' You could also use the feed operator perl6 -e ' lines() ==> map({split(",", $_)}) ==> classify( {.[0]}, :as{.[1]}) ==> sort() # optional ==> map({ say .key; say "\t$_" for .value.unique })' in.csv Brian
Re: split to walk into an HoH ?
hello, > You could also use the feed operator is there a reason to do so? i see none. regards marc
need windows loop help
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. 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 ""; } 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
for by 3?
Hi All, In a "for" loop, what is the syntax for "by 3"? for @x.lines by 3 In other words, every third line. Many thanks, -T
Re: need windows loop help
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. 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 ""; } 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?
Re: need windows loop help
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. > > > > > 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 ""; > } > > > 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 >
Re: need windows loop help
On 2019-11-22 22:33, Raymond Dresens wrote: 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'? That was it. I was remembering when I broke a YUGE string full of line feed into individual strings. That does not work with an array. Thank you!
which windows am I in?
Hi All, In Perl6 for Windows, how do I tell if I am in Windows 7 or 10? Many thanks, -T