Re: nil mystery
On 04/30/2018 05:20 PM, Andrew Kirkpatrick wrote: I couldn't reproduce this by assigning Nil to a variable Well as it transpires, when I tested the {$x} version, I forgot to press "save". Also, a one liner operated differently than a program. And to top things off, when reading "this" data back from the secondary clipboard, a nil got stuck at the end of the string. I use ${x} a lot in bash and Perl5, so {$x} in Perl6 is my preference too. Good times!
Re: nil mystery
On Sun, Apr 29, 2018 at 10:20:48PM -0700, ToddAndMargo wrote: On 04/29/2018 10:12 PM, ToddAndMargo wrote: On 04/29/2018 09:32 PM, Andrew Kirkpatrick wrote: There is not enough context to answer or even reproduce the problem - how are the variables declared and what values do they have just prior to this line? Some simpler examples: $ perl6 -e 'my $x="abcde"; say $x;' abcde $ perl6 -e 'my $x="abcde"; my $y="$x" ~ ""; say $y;' abcde $ perl6 -e 'my $x="abcde"; my $y="$x"; say $y;' Type Str does not support associative indexing. in block at -e line 1 $ perl6 -e 'my $x="abcde"; my $y="{$x}"; say $y;' abcde $ perl6 -e 'my $x="abcde"; my $y="$x\
"; say $y;' abcde So when is "<" and ">" a letter and when is it a redirect? On 04/30/2018 12:09 AM, Patrick Spek wrote: > It seems like in the one case it throws an error, it's because `<>` are being > used to index a hash. Or at least tried to. In Perl 6, you can access a Hash's > elements using `%foo`, which will access the index `bar` on the Hash > `%foo`. > > The other cases are explicitly not referring to a variable, or have delimiters > in place to make it known to the compiler that you're not trying to access a > Hash index. > > The error you're getting is "Type Str does not support associative indexing.", > which is correct, though perhaps a little unexpected for you. `$x` contains a > Str, not a Hash, but the `` still try to retrieve the index `br` from it. > The solution is to use any of the other options you're using, with my personal > preference going out to `{$x}`. > Hi Patrick, Now it makes sense. It was trying to resolve a hash. Thank you! -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
Re: nil mystery
On 04/29/2018 10:12 PM, ToddAndMargo wrote: On 04/29/2018 09:32 PM, Andrew Kirkpatrick wrote: There is not enough context to answer or even reproduce the problem - how are the variables declared and what values do they have just prior to this line? Some simpler examples: $ perl6 -e 'my $x="abcde"; say $x;' abcde $ perl6 -e 'my $x="abcde"; my $y="$x" ~ ""; say $y;' abcde $ perl6 -e 'my $x="abcde"; my $y="$x"; say $y;' Type Str does not support associative indexing. in block at -e line 1 $ perl6 -e 'my $x="abcde"; my $y="{$x}"; say $y;' abcde $ perl6 -e 'my $x="abcde"; my $y="$x\
"; say $y;' abcde So when is "<" and ">" a letter and when is it a redirect?
Re: nil mystery
On 04/29/2018 09:32 PM, Andrew Kirkpatrick wrote: There is not enough context to answer or even reproduce the problem - how are the variables declared and what values do they have just prior to this line? Also, what version of rakudo? On 30 April 2018 at 11:29, ToddAndMargowrote: Hi All, These two throw an operating on a "Nil" error: $PartsStr ~= "$PartNo"; $PartsStr ~= "{$PartNo}"; But this does not: $PartsStr ~= "{$PartNo}" ~ ""; And this does not either: $PartsStr ~= "abcde"; Huh? Many thanks, -T $ perl6 -v This is Rakudo version 2018.02.1 built on MoarVM version 2018.02 implementing Perl 6.c. sub TransferParts() { my $ClipStr; my $PartNo; my $Description; my $Qty; my $ItemPrice; $ClipStr = ReadSecondaryClipboard(); # PrintRed( "$ClipStr\n" ); # for split( '', $ClipStr ) -> $Char { say "$Char = <", ord( $Char ), ">" }; $ClipStr ~~ s:global/ ord( 10 )/"\n"/; for split( "\n", $ClipStr ) -> $Line { if not $Line { last }; # PrintBlue( "<$Line>\n" ); # for split( '', $Line ) -> $Char { say "$Char = <", ord( $Char ), ">" }; say "\n\n"; $Line ~~ m/(.*?)\t(.*?)\t(.*?)\t(.*)/; $PartNo = $0; $Description = $1; $Qty = $2; $ItemPrice = $3; # PrintBlue( "PartNo <$PartNo>\nDescription <$Description>\nQty <$Qty>\nItemPrice <$ItemPrice>\n\n" ); $PartsStr ~= "{$PartNo}" ~ ""; $PartsStr ~= "{$Description}" ~ ""; if $Qty > 1 { $PartsStr ~= "" }; $PartsStr ~= "Qty = {$Qty}" ~ ""; if $Qty > 1 { $PartsStr ~= "" }; $PartsStr ~= "Item Price ~{$ItemPrice}" ~ ""; $PartsStr ~= ""; } }
Re: nil mystery
There is not enough context to answer or even reproduce the problem - how are the variables declared and what values do they have just prior to this line? Also, what version of rakudo? On 30 April 2018 at 11:29, ToddAndMargowrote: > Hi All, > > These two throw an operating on a "Nil" error: > $PartsStr ~= "$PartNo"; > $PartsStr ~= "{$PartNo}"; > > > But this does not: > $PartsStr ~= "{$PartNo}" ~ ""; > > > And this does not either: > $PartsStr ~= "abcde"; > > Huh? > > > Many thanks, > -T > > -- > ~~~ > Serious error. > All shortcuts have disappeared. > Screen. Mind. Both are blank. > ~~~
nil mystery
Hi All, These two throw an operating on a "Nil" error: $PartsStr ~= "$PartNo"; $PartsStr ~= "{$PartNo}"; But this does not: $PartsStr ~= "{$PartNo}" ~ ""; And this does not either: $PartsStr ~= "abcde"; Huh? Many thanks, -T -- ~~~ Serious error. All shortcuts have disappeared. Screen. Mind. Both are blank. ~~~