Re: spurt and array question
Oh, now I see: you were asking that question in another thread. <<>> is equivalent to qq:ww:v as mentioned here: https://docs.raku.org/syntax/%3C%3C%20%3E%3E#index-entry-%3Aval_%28quoting_adverb%29 and as stated here: https://docs.raku.org/language/quoting the adverb :ww splits the string into words using whitespace characters as separators. Now, being "\n" a whitespace character, your string <> was split in three parts ("aaa", "bbb", "ccc") with no whitespace characters in them. On Sun, Nov 15, 2020 at 12:25 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-11-14 13:39, Fernando Santagata wrote: > > What do you mean by putting the \n in the variable? > > $ p6 'my @x = <>; for @x {"$_".print};' > aaabbbccc > > Why are the \n's not being resolved in the above? > > Why do I have to add an \n to the print line? > > $ p6 'my @x = <>; for @x {"$_\n".print};' > aaa > bbb > ccc > > Oh I see, because they are not actually in the cell: > > $ p6 'my @x = <>; dd @x' > Array @x = ["aaa", "bbb", "ccc"] > -- Fernando Santagata
Re: \n and array question
On 2020-11-14 18:03, Bruce Gray wrote: On Nov 14, 2020, at 2:06 PM, ToddAndMargo via perl6-users wrote: —snip— But my question still holds. Why is the \n inside the cell printed literally? The two characters, backslash and `n`, are output literally, because you have *input* them literally. In single quotes, the backslash does not combine with the `n` at all. They both remain separate characters. Single angle brackets follow single quoting rules, and only then split on whitespace. When you said: my @x = <"aaa\n","bbb\n","ccc\n">; , you populated @x with only one element. That element is a single 23-character string, with no whitespace in it. Example code, for exploration: my @z = "\n" , # 1 char : newline '\n' , # 2 chars: backslash, 'n' <\n> , # 2 chars: backslash, 'n' <<\n>> , # Empty list: because newline is whitespace, so it vanishes "a \n b" , # 5 chars: 'a', newline, 'b' 'a \n b' , # 6 chars: 'a', backslash, 'n', 'b' , # List of 3 elements, of lengths 1,2,1: 'a', '\n', ‘b’ The only whitespaces are the two separate space characters (one on the left of the backslash character, and one to the right of the ’n’ character), hence the word-quoting creates 3 elements. <> , # List of 2 elements, each is 1 char: 'a', 'b’; The “space newline space” is all a big chunk of whitespace, and the word-quoting effect just uses it to separate ‘a’ and ‘b' ; say $_ ~~ Str ?? .chars !! .list».chars for @z; say ''; dd $_ for @z; Output: 1 2 2 () 5 6 (1 2 1) (1 1) Str @z = "\n" Str @z = "\\n" Str @z = "\\n" List @z = $( ) Str @z = "a \n b" Str @z = "a \\n b" List @z = $("a", "\\n", "b") List @z = $("a", "b") — Hope this helps, Bruce Gray (Util of PerlMonks) Hi Bruce, Yes it was helpful: $ p6 'my @x = "aaa\n", "bbb\n", "ccc\n"; dd @x; say @x; for @x {print "$_";}' Array @x = ["aaa\n", "bbb\n", "ccc\n"] [aaa bbb ccc ] aaa bbb ccc Joy! Thank you! -T
Re: \n and array question
> On Nov 14, 2020, at 2:06 PM, ToddAndMargo via perl6-users > wrote: —snip— > But my question still holds. > Why is the \n inside the cell printed literally? The two characters, backslash and `n`, are output literally, because you have *input* them literally. In single quotes, the backslash does not combine with the `n` at all. They both remain separate characters. Single angle brackets follow single quoting rules, and only then split on whitespace. When you said: my @x = <"aaa\n","bbb\n","ccc\n">; , you populated @x with only one element. That element is a single 23-character string, with no whitespace in it. Example code, for exploration: my @z = "\n" , # 1 char : newline '\n' , # 2 chars: backslash, 'n' <\n> , # 2 chars: backslash, 'n' <<\n>> , # Empty list: because newline is whitespace, so it vanishes "a \n b" , # 5 chars: 'a', newline, 'b' 'a \n b' , # 6 chars: 'a', backslash, 'n', 'b' , # List of 3 elements, of lengths 1,2,1: 'a', '\n', ‘b’ The only whitespaces are the two separate space characters (one on the left of the backslash character, and one to the right of the ’n’ character), hence the word-quoting creates 3 elements. <> , # List of 2 elements, each is 1 char: 'a', 'b’; The “space newline space” is all a big chunk of whitespace, and the word-quoting effect just uses it to separate ‘a’ and ‘b' ; say $_ ~~ Str ?? .chars !! .list».chars for @z; say ''; dd $_ for @z; Output: 1 2 2 () 5 6 (1 2 1) (1 1) Str @z = "\n" Str @z = "\\n" Str @z = "\\n" List @z = $( ) Str @z = "a \n b" Str @z = "a \\n b" List @z = $("a", "\\n", "b") List @z = $("a", "b") — Hope this helps, Bruce Gray (Util of PerlMonks)
Re: ps?
On 2020-11-13 18:26, Curt Tilmes wrote: On Fri, Nov 13, 2020 at 9:03 PM ToddAndMargo via perl6-users wrote: Fedora 33 I know I can get this information from a system call to "ps", but is there a way to tell if a program in running from Raku? Running ps is probably as good as anything, but in linux you could always just poke around under /proc, e.g. Loop over /proc/*/cmdline and look for it. Follow up: $PsStr = qqx ( ps ax ); if $PsStr.contains( "gnucash" ) { PrintGreen( "GnuCash is running\n\n" ); } else { # qqx ( gnucash ); my $pA = Proc::Async.new( "/usr/bin/gnucash" ); $pA.start; PrintGreen( "GnuCash started\n\n" ); }
Re: spurt and array question
On 2020-11-14 13:39, Fernando Santagata wrote: What do you mean by putting the \n in the variable? $ p6 'my @x = <>; for @x {"$_".print};' aaabbbccc Why are the \n's not being resolved in the above? Why do I have to add an \n to the print line? $ p6 'my @x = <>; for @x {"$_\n".print};' aaa bbb ccc Oh I see, because they are not actually in the cell: $ p6 'my @x = <>; dd @x' Array @x = ["aaa", "bbb", "ccc"]
Re: I need to run and release a program in the background
On 2020-11-14 13:14, ToddAndMargo via perl6-users wrote: On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote: Hi All, How do I use qqx or other to run and release a program in the background, like bash's "&"? Many thanks, -T The guys on hte chat line figured it out for me: $ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise = $pA.start;' My keeper on the subject: How to run and release a file: Note: this command runs OUTSIDE the shell. There are no environmental variables to be found such as $HOME the parpameters are in quotes, including the name of the program to run, just like `run` $ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise = $pA.start; await $promise;' $ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); $pA.start;' $ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad", "/home/linuxutil/XferParts.pl6.tmp" ); $pA.start;' To get this to run with the shell, call "bash -c" my $pA = Proc::Async.new( "bash", "-c", "/usr/bin/leafpad /home/linuxutil/XferParts.pl6.tmp" ); $pA.start;
Re: spurt and array question
On Sat, Nov 14, 2020 at 9:02 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > Maybe this is what you want: > > > > my @a = 1,2,3; > > spurt('test', @a.join("\n") ~ "\n"); # join doesn't add the last "\n" > > > > Or the equivalent > > > > 'test'.IO.spurt: @a.join("\n") ~ "\n"; > > That is the way around the issue. > > But my question is why can I not put the \n in the variable? > What do you mean by putting the \n in the variable? Is it anything like this? [¹] my @a = "1\n", "2\n", "3\n"; 'test'.IO.spurt(@a); or this? my @a = ; 'test'.IO.spurt(@a »~» "\n"); [¹] Mind that the array is first converted into a string and its elements are joined together with an interleaving space -- Fernando Santagata
Re: I need to run and release a program in the background
On 2020-11-14 12:23, ToddAndMargo via perl6-users wrote: Hi All, How do I use qqx or other to run and release a program in the background, like bash's "&"? Many thanks, -T The guys on hte chat line figured it out for me: $ p6 'my $pA = Proc::Async.new( "/usr/bin/leafpad" ); my $promise = $pA.start;'
I need to run and release a program in the background
Hi All, How do I use qqx or other to run and release a program in the background, like bash's "&"? Many thanks, -T -- A computer without Microsoft is like a chocolate cake without the mustard
Re: \n and array question
On 2020-11-14 12:03, Brad Gilbert wrote: I pretty quickly caught my booboo after I pressed send. A little eggs on the face. But my question still holds. Why is the \n inside the cell printed literally?
Re: spurt and array question
On Sat, Nov 14, 2020 at 1:07 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: On 2020-11-14 06:00, Brad Gilbert wrote: > The purpose of `spurt` is to: > 1. open a NEW file to write to > 2. print a single string > 3. close the file > > If you are calling `spurt` more than once on a given file, you are doing > it wrong. You are forgetting that spurt comes with an `:append` option. > If you give `spurt` an array, you are probably doing it wrong > unless you want the array turned into a single string first. Ya, doing things the hard way. On 2020-11-14 11:51, Brad Gilbert wrote: Actually no I'm not “forgetting that spurt comes with an `:append` option”. That is a slightly different use case. It is where you are appending to an existing file once, and then never touching it again. (Or maybe you might be touching it again in a few hours.) --- Given that this is what you wrote: unlink( $Leafpadrc ); for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", :append ); } I want to know how this is the hard way: given $Leafpadrc.IO.open(:w) { for @LeafpadrcNew -> $Line { .put: $Line } .close; } or given $Leafpadrc.IO.open(:w) -> $*OUT { for @LeafpadrcNew -> $Line { put $Line } $*OUT.close; } or given $Leafpadrc.IO.open(:w) -> $*OUT { .put for @LeafpadrcNew; $*OUT.close; } or given $Leafpadrc.IO.open(:w, :!out-buffer) -> $*OUT { .put for @LeafpadrcNew; } I was saying I was doing it the hard way, not you. Wonderful examples. Thank you!
Re: \n and array question
is the same as Q :single :words < a b c > Note that :single means it acts like single quotes. Single quotes don't do anything to convert '\n' into anything other than a literal '\n'. If you want that to be converted to a linefeed you need to use double quote semantics (or at least turn on :backslash). Q :double :words < a\n b\n c > Of course that also doesn't do what you want because a linefeed character is also whitespace, so it gets removed along with the rest of the whitespace. What you want to do use is :quotewords and "". Q :quotewords < "a\n" "b\n" c > The short way to write that is << "a\n" "b\n" c >> Although if you are going to append a newline to every element I would consider writing it this way: < a b c > X~ "\n" or < a b c > »~» "\n" On Sat, Nov 14, 2020 at 1:21 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > >> On Nov 14, 2020, at 14:12, ToddAndMargo via perl6-users > wrote: > >> > >> On 2020-11-14 11:08, Curt Tilmes wrote: > >>> On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users > >>> 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 = ; for @x {print "$_\n";}' > >> aaa\n > >> bbb\n > >> ccc\n > >> > >> $ p6 'my @x = <>; for @x {print "$_\n";}' > >> aaa > >> bbb > >> ccc > >> > >> $ p6 'my @x = <>; 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 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, 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., , 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? >
Re: spurt and array question
On 2020-11-14 11:22, Fernando Santagata wrote: On Sat, Nov 14, 2020 at 8:07 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: On 2020-11-14 06:00, Brad Gilbert wrote: > The purpose of `spurt` is to: > 1. open a NEW file to write to > 2. print a single string > 3. close the file > > If you are calling `spurt` more than once on a given file, you are doing > it wrong. You are forgetting that spurt comes with an `:append` option. Maybe this is what you want: my @a = 1,2,3; spurt('test', @a.join("\n") ~ "\n"); # join doesn't add the last "\n" Or the equivalent 'test'.IO.spurt: @a.join("\n") ~ "\n"; -- Fernando Santagata That is the way around the issue. But my question is why can I not put the \n in the variable?
Re: spurt and array question
On 2020-11-14 03:15, Tom Browder wrote: On Sat, Nov 14, 2020 at 01:59 ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Hi All, I am writing out an array of text lines to a file. I just can't help but thinking I am doing it the hard way. unlink( $Leafpadrc ); for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", :append ); } Unless I misunderstand, why doesn't this work: my $fh = open $Leafpadrc, :w; $fh.say($_) for @Leafpadrc; -Tom unlink( $Leafpadrc ); $Leafpadrc.IO.open( :w ); Neither of these two actually updates the file. for @LeafpadrcNew -> $Line { put( $Leafpadrc, $Line ); } for @LeafpadrcNew -> $Line { $Leafpadrc.put( $Line ); }
Re: spurt and array question
Actually no I'm not “forgetting that spurt comes with an `:append` option”. That is a slightly different use case. It is where you are appending to an existing file once, and then never touching it again. (Or maybe you might be touching it again in a few hours.) --- Given that this is what you wrote: unlink( $Leafpadrc ); for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", :append ); } I want to know how this is the hard way: given $Leafpadrc.IO.open(:w) { for @LeafpadrcNew -> $Line { .put: $Line } .close; } or given $Leafpadrc.IO.open(:w) -> $*OUT { for @LeafpadrcNew -> $Line { put $Line } $*OUT.close; } or given $Leafpadrc.IO.open(:w) -> $*OUT { .put for @LeafpadrcNew; $*OUT.close; } or given $Leafpadrc.IO.open(:w, :!out-buffer) -> $*OUT { .put for @LeafpadrcNew; } On Sat, Nov 14, 2020 at 1:07 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-11-14 06:00, Brad Gilbert wrote: > > The purpose of `spurt` is to: > > 1. open a NEW file to write to > > 2. print a single string > > 3. close the file > > > > If you are calling `spurt` more than once on a given file, you are doing > > it wrong. > > You are forgetting that spurt comes with an `:append` option. > > > If you give `spurt` an array, you are probably doing it wrong > > unless you want the array turned into a single string first. > > Ya, doing things the hard way. >
Re: spurt and array question
On 2020-11-14 03:59, Gianni Ceccarelli wrote: $Leafpadrc.put($_) for @LeafpadrcNew; Cannot resolve caller print(Str:D: BOOTStr); none of these signatures match: (Mu: *%_) in sub RunReport at ./XferParts.pl6 line 229 229: $Leafpadrc.put($_) for @LeafpadrcNew; -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
Re: spurt and array question
On Sat, Nov 14, 2020 at 8:07 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-11-14 06:00, Brad Gilbert wrote: > > The purpose of `spurt` is to: > > 1. open a NEW file to write to > > 2. print a single string > > 3. close the file > > > > If you are calling `spurt` more than once on a given file, you are doing > > it wrong. > > You are forgetting that spurt comes with an `:append` option. > Maybe this is what you want: my @a = 1,2,3; spurt('test', @a.join("\n") ~ "\n"); # join doesn't add the last "\n" Or the equivalent 'test'.IO.spurt: @a.join("\n") ~ "\n"; -- Fernando Santagata
Re: \n and array question
>> On Nov 14, 2020, at 14:12, ToddAndMargo via perl6-users wrote: >> >> On 2020-11-14 11:08, Curt Tilmes wrote: >>> On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users >>> 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 = ; for @x {print "$_\n";}' >> aaa\n >> bbb\n >> ccc\n >> >> $ p6 'my @x = <>; for @x {print "$_\n";}' >> aaa >> bbb >> ccc >> >> $ p6 'my @x = <>; 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 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, , 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., , 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?
Re: \n and array question
The <…> and «…» constructors break on whitespace. So 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, , 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., , you allow it to break into ["a", "b", "c", "d", "e", "f"] Matéu > On Nov 14, 2020, at 14:12, ToddAndMargo via perl6-users > wrote: > > On 2020-11-14 11:08, Curt Tilmes wrote: >> On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users >> 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 = ; for @x {print "$_\n";}' > aaa\n > bbb\n > ccc\n > > $ p6 'my @x = <>; for @x {print "$_\n";}' > aaa > bbb > ccc > > $ p6 'my @x = <>; for @x {print "$_";}' > aaabbbccc > > What am I missing? > > -T > > -- > ~~ > Computers are like air conditioners. > They malfunction when you open windows > ~~
Re: \n and array question
On 2020-11-14 11:08, Curt Tilmes wrote: On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users 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 = ; for @x {print "$_\n";}' aaa\n bbb\n ccc\n $ p6 'my @x = <>; for @x {print "$_\n";}' aaa bbb ccc $ p6 'my @x = <>; for @x {print "$_";}' aaabbbccc What am I missing? -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
Re: \n and array question
On Sat, Nov 14, 2020 at 2:03 PM ToddAndMargo via perl6-users 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
Re: spurt and array question
On 2020-11-14 06:00, Brad Gilbert wrote: The purpose of `spurt` is to: 1. open a NEW file to write to 2. print a single string 3. close the file If you are calling `spurt` more than once on a given file, you are doing it wrong. You are forgetting that spurt comes with an `:append` option. If you give `spurt` an array, you are probably doing it wrong unless you want the array turned into a single string first. Ya, doing things the hard way.
\n and array question
Hi All, Just out of curiosity, why is the \n printed out literally here? $ alias p6 alias p6='perl6 -e' p6 'my @x = <"aaa\n","bbb\n","ccc\n">; for @x {print @_};' "aaa\n","bbb\n","ccc\n" Many thanks, -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
Re: spurt and array question
The purpose of `spurt` is to: 1. open a NEW file to write to 2. print a single string 3. close the file If you are calling `spurt` more than once on a given file, you are doing it wrong. If you give `spurt` an array, you are probably doing it wrong; unless you want the array turned into a single string first. `spurt` is the dual of `slurp`. The purpose of `slurp` is to: 1. open an existing file to read from 2. read the whole file into a single string 3. close the file That is they are only short-cuts for a simple combination of operations. If you are opening a file for only the express purpose of reading ALL of its contents into a SINGLE STRING, use `slurp`. If you are opening a file for only the express purpose of writing ALL of its contents from a SINGLE STRING, use `spurt`. If you are doing anything else, use something else. --- Assuming you want to loop over a bunch of strings to print to a file, use `open` and `print`/`put`/`say`. This is also faster than calling `spurt` more than once because you only open and close the file once. If you want there to be only one call, turn your array into the appropriate single string first. On Sat, Nov 14, 2020 at 1:59 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > I am writing out an array of text lines to a file. > I just can't help but thinking I am doing it the > hard way. > > unlink( $Leafpadrc ); > for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", > :append ); } > > If I spurt the array, it converts the array into a > single text line. > > The test file looks like this: > > ./.config/leafpad/leafpadrc > $ cat leafpadrc > 0.8.18.1 > 500 > 190 > Monospace 12 > 1 > 1 > 0 > > Your thoughts? > > -T > > -- > ~~ > Computers are like air conditioners. > They malfunction when you open windows > ~~ >
Re: spurt and array question
On 2020-11-13 ToddAndMargo via perl6-users wrote: > Hi All, > > I am writing out an array of text lines to a file. > I just can't help but thinking I am doing it the > hard way. > > unlink( $Leafpadrc ); > for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", > :append ); } > > If I spurt the array, it converts the array into a > single text line. Some alternatives: $Leafpadrc.spurt(@LeafpadrcNew.join($Leafpadrc.nl-out)); $Leafpadrc.put($_) for @LeafpadrcNew; -- Dakkar - GPG public key fingerprint = A071 E618 DD2C 5901 9574 6FE2 40EA 9883 7519 3F88 key id = 0x75193F88
Re: Junctions wrapped in singleton lists
On 2020-11-13 Sean McAfee wrote: > I just tried making a sequence of junctions and found that each one > ended up wrapped in a singleton list somehow: > > > ({ 1 | -1 } ... *)[^3] > ((any(1, -1)) (any(1, -1)) (any(1, -1))) oh, that's weird:: > ({ 'a' } ... *)[0].^name Str > ({ any(1,2) } ... *)[0].^name List > { any(1,2) }().^name Junction -- Dakkar - GPG public key fingerprint = A071 E618 DD2C 5901 9574 6FE2 40EA 9883 7519 3F88 key id = 0x75193F88
Re: spurt and array question
On Sat, Nov 14, 2020 at 01:59 ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > I am writing out an array of text lines to a file. > I just can't help but thinking I am doing it the > hard way. > > unlink( $Leafpadrc ); > for @LeafpadrcNew -> $Line { spurt( $Leafpadrc, $Line ~ "\n", > :append ); } > Unless I misunderstand, why doesn't this work: my $fh = open $Leafpadrc, :w; $fh.say($_) for @Leafpadrc; -Tom