How do I trap a crash?
Hi All, I would like to do a Send Notify when a program of mine crashes. How do I trap a crash? Is there a way to see some of the local variables in the sub that crashes with the trap? Many thanks, -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
I need hash inside a hash help
Hi All, How do I do a hash inside a hash? So far I have: $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 ) ); say %Vendors;' ===SORRY!=== Error while compiling -e I want to be able to have both a Contact Name and and AccountNo associated with each key in %Vendors. Many thanks, -T
Re: How do I trap a crash?
Perhaps https://docs.perl6.org/language/exceptions#Catching_exceptions could be enlightening? > On 11 Jan 2019, at 18:54, ToddAndMargo via perl6-users > wrote: > > Hi All, > > I would like to do a Send Notify when a program of mine > crashes. > > How do I trap a crash? > > Is there a way to see some of the local variables in the > sub that crashes with the trap? > > > Many thanks, > -T > > > -- > ~~ > Computers are like air conditioners. > They malfunction when you open windows > ~~
Re: How do I trap a crash?
>> Hi All, >> >> I would like to do a Send Notify when a program of mine >> crashes. >> >> How do I trap a crash? >> >> Is there a way to see some of the local variables in the >> sub that crashes with the trap? >> >> >> Many thanks, >> -T On 1/11/19 10:56 AM, Elizabeth Mattijsen wrote: Perhaps https://docs.perl6.org/language/exceptions#Catching_exceptions could be enlightening? On 11 Jan 2019, at 18:54, ToddAndMargo via perl6-users wrote: Yes. Thank you! CATCH { default { $*ERR.say: .payload; for .backtrace.reverse { next if .file.starts-with('SETTING::'); next unless .subname; $*ERR.say: " in block {.subname} at {.file} line {.line}"; } } } Does the program die afterward? Each of my subs has my Str $SubName = &?ROUTINE.name; Is there a way to get that in the printout from CATCH? Many thanks, -T
Re: I need hash inside a hash help
What would you say is the error, according to where the arrow points to? Maybe some unclosed double quotes? El vie., 11 ene. 2019 a las 19:57, ToddAndMargo via perl6-users (< perl6-us...@perl.org>) escribió: > Hi All, > > How do I do a hash inside a hash? > > So far I have: > > $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => > 1234 ) ); say %Vendors;' > ===SORRY!=== Error while compiling -e > > > I want to be able to have both a Contact Name and and AccountNo > associated with each key in %Vendors. > > > Many thanks, > -T > -- JJ
Re: I need hash inside a hash help
Hi Todd, the error you're getting comes from a closing quotation mark missing after "Larry You will also need to give perl6 some hint that you want the list of pairs to actually become a hash. To do that, I would recommend just putting a % in front of the () The working code looks like this: perl6 -e 'my %Vendors=("acme" => %( "ContactName" => "Larry", "AccountNo" => 1234 ) ); say %Vendors;' {acme => {AccountNo => 1234, ContactName => Larry}} Hope that helps! - Timo On 11/01/2019 19:41, ToddAndMargo via perl6-users wrote: > Hi All, > > How do I do a hash inside a hash? > > So far I have: > > $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => > 1234 ) ); say %Vendors;' > ===SORRY!=== Error while compiling -e > > > I want to be able to have both a Contact Name and and AccountNo > associated with each key in %Vendors. > > > Many thanks, > -T
Re: I need hash inside a hash help
On 1/11/19 11:09 AM, Timo Paulssen wrote: Hi Todd, the error you're getting comes from a closing quotation mark missing after "Larry You will also need to give perl6 some hint that you want the list of pairs to actually become a hash. To do that, I would recommend just putting a % in front of the () The working code looks like this: perl6 -e 'my %Vendors=("acme" => %( "ContactName" => "Larry", "AccountNo" => 1234 ) ); say %Vendors;' {acme => {AccountNo => 1234, ContactName => Larry}} Hope that helps! - Timo On 11/01/2019 19:41, ToddAndMargo via perl6-users wrote: Hi All, How do I do a hash inside a hash? So far I have: $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 ) ); say %Vendors;' ===SORRY!=== Error while compiling -e I want to be able to have both a Contact Name and and AccountNo associated with each key in %Vendors. Many thanks, -T Hi Timo, Thank you! Ah man. I took my best shot at it and got nailed by a stinkin' typo. :'( -T
Re: I need hash inside a hash help
> On Jan 11, 2019, at 12:41 PM, ToddAndMargo via perl6-users > wrote: > > Hi All, > > How do I do a hash inside a hash? > > So far I have: > > $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 ) > ); say %Vendors;' > ===SORRY!=== Error while compiling -e > > > I want to be able to have both a Contact Name and and AccountNo > associated with each key in %Vendors. > > > Many thanks, > -T First, you need a double-quote after `Larry` (before the comma) to fix the syntax error: perl6 -e 'my %Vendors=("acme" => ( "ContactName" => "Larry", "AccountNo" => 1234 ) ); say %Vendors;' At this point, you have a Hash of List of Pairs. To change it into a Hash of Hashes, change the inner parens to curly braces: perl6 -e 'my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 } ); say %Vendors; say %Vendors;' Those inner parens were acting as an anonymous list constructor, but you needed an anonymous *hash* constructor, which is what the curly braces do (when they are not doing their code-block-ish job). You could have also used `Hash(…)` or `%(…)` instead of `{…}`, but `{…} is shortest, and most traditional from Perl 5. — Hope this helps, Bruce Gray (Util of PerlMonks)
Re: I need hash inside a hash help
On 1/11/19 11:07 AM, JJ Merelo wrote: What would you say is the error, according to where the arrow points to? Maybe some unclosed double quotes? El vie., 11 ene. 2019 a las 19:57, ToddAndMargo via perl6-users (mailto:perl6-us...@perl.org>>) escribió: Hi All, How do I do a hash inside a hash? So far I have: $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 ) ); say %Vendors;' ===SORRY!=== Error while compiling -e I want to be able to have both a Contact Name and and AccountNo associated with each key in %Vendors. Many thanks, -T -- JJ I missed the quote after Larry. Timo found it for me.
Re: I need hash inside a hash help
On 1/11/19 11:12 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:09 AM, Timo Paulssen wrote: Hi Todd, the error you're getting comes from a closing quotation mark missing after "Larry You will also need to give perl6 some hint that you want the list of pairs to actually become a hash. To do that, I would recommend just putting a % in front of the () The working code looks like this: perl6 -e 'my %Vendors=("acme" => %( "ContactName" => "Larry", "AccountNo" => 1234 ) ); say %Vendors;' {acme => {AccountNo => 1234, ContactName => Larry}} Hope that helps! - Timo On 11/01/2019 19:41, ToddAndMargo via perl6-users wrote: Hi All, How do I do a hash inside a hash? So far I have: $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 ) ); say %Vendors;' ===SORRY!=== Error while compiling -e I want to be able to have both a Contact Name and and AccountNo associated with each key in %Vendors. Many thanks, -T Hi Timo, Thank you! Ah man. I took my best shot at it and got nailed by a stinkin' typo. :'( -T Not to ask too stupid a question, but how do I get the values back out? p6 'my %Vendors=("acme" => ( "ContactName" => "Larry", "AccountNo" => 1234 ), "Ace" => ( "ContactName" => "Mo", "AccountNo" => "A102" ); say %Vendors<"Ace"<"ContactName">>;'
Re: I need hash inside a hash help
On 1/11/19 11:16 AM, Bruce Gray wrote: On Jan 11, 2019, at 12:41 PM, ToddAndMargo via perl6-users wrote: Hi All, How do I do a hash inside a hash? So far I have: $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 ) ); say %Vendors;' ===SORRY!=== Error while compiling -e I want to be able to have both a Contact Name and and AccountNo associated with each key in %Vendors. Many thanks, -T First, you need a double-quote after `Larry` (before the comma) to fix the syntax error: perl6 -e 'my %Vendors=("acme" => ( "ContactName" => "Larry", "AccountNo" => 1234 ) ); say %Vendors;' At this point, you have a Hash of List of Pairs. To change it into a Hash of Hashes, change the inner parens to curly braces: perl6 -e 'my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 } ); say %Vendors; say %Vendors;' Those inner parens were acting as an anonymous list constructor, but you needed an anonymous *hash* constructor, which is what the curly braces do (when they are not doing their code-block-ish job). You could have also used `Hash(…)` or `%(…)` instead of `{…}`, but `{…} is shortest, and most traditional from Perl 5. — Hope this helps, Bruce Gray (Util of PerlMonks) Hi Bruce, Thank you! This works, $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors" ~ "\t" ~ "%Vendors";' Mo A102 but I have to access it by a variable. "Now" what am I doing wrong? $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<$Ace>" ~ "\t" ~ "%Vendors<$Ace>";' Use of uninitialized value of type Any in string context. Many thanks, -T
Re: I need hash inside a hash help
I think you want $x, not $Ace. Cheers El vie., 11 ene. 2019 a las 20:26, ToddAndMargo via perl6-users (< perl6-us...@perl.org>) escribió: > On 1/11/19 11:16 AM, Bruce Gray wrote: > > > > > >> On Jan 11, 2019, at 12:41 PM, ToddAndMargo via perl6-users < > perl6-us...@perl.org> wrote: > >> > >> Hi All, > >> > >> How do I do a hash inside a hash? > >> > >> So far I have: > >> > >> $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => > 1234 ) ); say %Vendors;' > >> ===SORRY!=== Error while compiling -e > >> > >> > >> I want to be able to have both a Contact Name and and AccountNo > >> associated with each key in %Vendors. > >> > >> > >> Many thanks, > >> -T > > > > First, you need a double-quote after `Larry` (before the comma) to fix > the syntax error: > > perl6 -e 'my %Vendors=("acme" => ( "ContactName" => "Larry", > "AccountNo" => 1234 ) ); say %Vendors;' > > > > At this point, you have a Hash of List of Pairs. To change it into a > Hash of Hashes, change the inner parens to curly braces: > > perl6 -e 'my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 } ); say %Vendors; say %Vendors;' > > > > Those inner parens were acting as an anonymous list constructor, but you > needed an anonymous *hash* constructor, which is what the curly braces do > (when they are not doing their code-block-ish job). > > > > You could have also used `Hash(…)` or `%(…)` instead of `{…}`, but `{…} > is shortest, and most traditional from Perl 5. > > > > — > > Hope this helps, > > Bruce Gray (Util of PerlMonks) > > > > Hi Bruce, > > Thank you! > > This works, > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors" ~ "\t" ~ > "%Vendors";' > Mo A102 > > > but I have to access it by a variable. "Now" what am I doing wrong? > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<$Ace>" ~ "\t" ~ > "%Vendors<$Ace>";' > Use of uninitialized value of type Any in string context. > > > Many thanks, > -T > -- JJ
Re: I need hash inside a hash help
On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup. I am on fire today! :'( Still can't get it figured out. :'( :'( $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<$x>" ~ "\t" ~ "%Vendors<$x>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<"$x">" ~ "\t" ~ "%Vendors<"$x">";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{$x}>" ~ "\t" ~ "%Vendors<{$x}>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{"$x"}>" ~ "\t" ~ "%Vendors<{"$x"}>";' Use of uninitialized value of type Any in string context. I can't win.
Re: I need hash inside a hash help
On 1/11/19 11:39 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup. I am on fire today! :'( Still can't get it figured out. :'( :'( $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<$x>" ~ "\t" ~ "%Vendors<$x>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<"$x">" ~ "\t" ~ "%Vendors<"$x">";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{$x}>" ~ "\t" ~ "%Vendors<{$x}>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{"$x"}>" ~ "\t" ~ "%Vendors<{"$x"}>";' Use of uninitialized value of type Any in string context. I can't win. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<<$x>>" ~ "\t" ~ "%Vendors<<$x>>";' ===SORRY!=== Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1) at -e:1 --> >" ~ "\t" ~ "%Vendors<<$x>>";⏏ expecting any of: double quotes postfix Other potential difficulties: Ambiguous use of >>; use » instead to mean hyper, or insert whitespace before >> to mean a quote terminator (or use different delimiters?) at -e:1 --> 2" } ); say "%Vendors<<$x>>⏏" ~ "\t" ~ "%Vendors<<$x>>"; Ambiguous use of >>; use » instead to mean hyper, or insert whitespace before >> to mean a quote terminator (or use different delimiters?) at -e:1 --> me>" ~ "\t" ~ "%Vendors<<$x>>⏏";
Re: I need hash inside a hash help
You don't need to quote "%Vendors<{"$x"}>"By doing so, you're closing the quotes right behind { Cheers El vie., 11 ene. 2019 a las 20:39, ToddAndMargo via perl6-users (< perl6-us...@perl.org>) escribió: > On 1/11/19 11:33 AM, JJ Merelo wrote: > > I think you want $x, not $Ace. > > > > Cheers > > Yup. I am on fire today! :'( > > Still can't get it figured out. :'( :'( > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<$x>" ~ "\t" ~ > "%Vendors<$x>";' > Use of uninitialized value of type Any in string context. > > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<"$x">" ~ "\t" ~ > "%Vendors<"$x">";' > Use of uninitialized value of type Any in string context. > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<{$x}>" ~ "\t" ~ > "%Vendors<{$x}>";' > Use of uninitialized value of type Any in string context. > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<{"$x"}>" ~ "\t" ~ > "%Vendors<{"$x"}>";' > Use of uninitialized value of type Any in string context. > > > I can't win. > -- JJ
Re: I need hash inside a hash help
Short answer: use `%hash{$var}`, not `%hash<$var>`. When they are not in position to be less-than and greater-than comparison operators, the pair of left and right angle brackets are a circumfix operator that work like Perl 5’s “quote word” op: `qw()`. In Perl 6, `<>` are used a lot, including as a shortcut in hash lookups. The full form for looking up the constant key `acme` in %Vendors is to use curly braces and to *quote* the key (single or double quote), or have the key in a variable: say %Vendors{'acme’}; say %Vendors{"acme”}; my $k = ‘acme’; say %Vendors{$k}; The shortcut of replacing the curly braces with angle brackets only works for constant strings: say %Vendors; Advanced note: Since `<>` produce a *list* of quoted words, you can use them to extract multiple values from a hash: my ( $acct, $cn ) = %Vendors{"acme"}{"AccountNo", "ContactName”}; my ( $acct, $cn ) = %Vendors; say [:$acct, :$cn].perl; -- Hope this helps, Bruce Gray (Util of PerlMonks) > On Jan 11, 2019, at 1:25 PM, ToddAndMargo via perl6-users > wrote: > > On 1/11/19 11:16 AM, Bruce Gray wrote: >>> On Jan 11, 2019, at 12:41 PM, ToddAndMargo via perl6-users >>> wrote: >>> >>> Hi All, >>> >>> How do I do a hash inside a hash? >>> >>> So far I have: >>> >>> $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 >>> ) ); say %Vendors;' >>> ===SORRY!=== Error while compiling -e >>> >>> >>> I want to be able to have both a Contact Name and and AccountNo >>> associated with each key in %Vendors. >>> >>> >>> Many thanks, >>> -T >> First, you need a double-quote after `Larry` (before the comma) to fix the >> syntax error: >> perl6 -e 'my %Vendors=("acme" => ( "ContactName" => "Larry", >> "AccountNo" => 1234 ) ); say %Vendors;' >> At this point, you have a Hash of List of Pairs. To change it into a Hash of >> Hashes, change the inner parens to curly braces: >> perl6 -e 'my %Vendors=("acme" => { "ContactName" => "Larry", >> "AccountNo" => 1234 } ); say %Vendors; say %Vendors;' >> Those inner parens were acting as an anonymous list constructor, but you >> needed an anonymous *hash* constructor, which is what the curly braces do >> (when they are not doing their code-block-ish job). >> You could have also used `Hash(…)` or `%(…)` instead of `{…}`, but `{…} is >> shortest, and most traditional from Perl 5. >> — >> Hope this helps, >> Bruce Gray (Util of PerlMonks) > > Hi Bruce, > > Thank you! > > This works, > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors" ~ "\t" ~ > "%Vendors";' > MoA102 > > > but I have to access it by a variable. "Now" what am I doing wrong? > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<$Ace>" ~ "\t" ~ > "%Vendors<$Ace>";' > Use of uninitialized value of type Any in string context. > > > Many thanks, > -T
Re: I need hash inside a hash help
> On Jan 11, 2019, at 1:39 PM, ToddAndMargo via perl6-users > wrote: > > On 1/11/19 11:33 AM, JJ Merelo wrote: >> I think you want $x, not $Ace. >> Cheers > > Yup. I am on fire today! :'( > > Still can't get it figured out. :'( :'( > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<$x>" ~ "\t" ~ > "%Vendors<$x>";' > Use of uninitialized value of type Any in string context. > > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<"$x">" ~ "\t" ~ > "%Vendors<"$x">";' > Use of uninitialized value of type Any in string context. > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<{$x}>" ~ "\t" ~ > "%Vendors<{$x}>";' > Use of uninitialized value of type Any in string context. > > $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", > "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => > "A102" } ); say "%Vendors<{"$x"}>" ~ "\t" ~ > "%Vendors<{"$x"}>";' > Use of uninitialized value of type Any in string context. > > > I can't win. This: <{"$x”}> should just be: {$x} (Lots of unneeded double-quotes trimmed) perl6 -e 'my $x = "Ace"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 }, Ace => { ContactName => "Mo", AccountNo => "A102" } ); say %Vendors{$x} ~ "\t" ~ %Vendors{$x};’
Re: I need hash inside a hash help
On 1/11/19 11:43 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:39 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup. I am on fire today! :'( Still can't get it figured out. :'( :'( $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<$x>" ~ "\t" ~ "%Vendors<$x>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<"$x">" ~ "\t" ~ "%Vendors<"$x">";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{$x}>" ~ "\t" ~ "%Vendors<{$x}>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{"$x"}>" ~ "\t" ~ "%Vendors<{"$x"}>";' Use of uninitialized value of type Any in string context. I can't win. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<<$x>>" ~ "\t" ~ "%Vendors<<$x>>";' ===SORRY!=== Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1) at -e:1 --> >" ~ "\t" ~ "%Vendors<<$x>>";⏏ expecting any of: double quotes postfix Other potential difficulties: Ambiguous use of >>; use » instead to mean hyper, or insert whitespace before >> to mean a quote terminator (or use different delimiters?) at -e:1 --> 2" } ); say "%Vendors<<$x>>⏏" ~ "\t" ~ "%Vendors<<$x>>"; Ambiguous use of >>; use » instead to mean hyper, or insert whitespace before >> to mean a quote terminator (or use different delimiters?) at -e:1 --> me>" ~ "\t" ~ "%Vendors<<$x>>⏏"; I got it finally. I had to switch from a one liner to an actual program #! /usr/bin/env perl6 my $x = "Ace"; my %Vendors = ( "acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo","AccountNo" => "A102" } ); print( %Vendors<< $x >> ~ "\t" ~ %Vendors<< $x >> ~ "\n" ); $ HashOfHashTest.pl6 Mo A102 And it demanded a white space in << $x >>
Re: I need hash inside a hash help
On 1/11/19 11:50 AM, Bruce Gray wrote: 'my $x = "Ace"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 }, Ace => { ContactName => "Mo", AccountNo => "A102" } ); say %Vendors{$x} ~ "\t" ~ %Vendors{$x};’ Hi Bruce, Sweet! Thank you! $ p6 'my $x = "Ace"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 }, Ace => { ContactName => "Mo", AccountNo => "A102" } ); say %Vendors{$x} ~ "\t" ~ %Vendors{$x};' Mo A102 -T
Re: I need hash inside a hash help
On 1/11/19 11:45 AM, Bruce Gray wrote: Short answer: use `%hash{$var}`, not `%hash<$var>`. When they are not in position to be less-than and greater-than comparison operators, the pair of left and right angle brackets are a circumfix operator that work like Perl 5’s “quote word” op: `qw()`. In Perl 6, `<>` are used a lot, including as a shortcut in hash lookups. The full form for looking up the constant key `acme` in %Vendors is to use curly braces and to*quote* the key (single or double quote), or have the key in a variable: say %Vendors{'acme’}; say %Vendors{"acme”}; my $k = ‘acme’; say %Vendors{$k}; The shortcut of replacing the curly braces with angle brackets only works for constant strings: say %Vendors; Advanced note: Since `<>` produce a*list* of quoted words, you can use them to extract multiple values from a hash: my ( $acct, $cn ) = %Vendors{"acme"}{"AccountNo", "ContactName”}; my ( $acct, $cn ) = %Vendors; say [:$acct, :$cn].perl; Yes it does help. I copied it to my hash Keepers file. Thank you!
Re: I need hash inside a hash help
On 1/11/19 11:50 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:43 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:39 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup. I am on fire today! :'( Still can't get it figured out. :'( :'( $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<$x>" ~ "\t" ~ "%Vendors<$x>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<"$x">" ~ "\t" ~ "%Vendors<"$x">";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{$x}>" ~ "\t" ~ "%Vendors<{$x}>";' Use of uninitialized value of type Any in string context. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<{"$x"}>" ~ "\t" ~ "%Vendors<{"$x"}>";' Use of uninitialized value of type Any in string context. I can't win. $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); say "%Vendors<<$x>>" ~ "\t" ~ "%Vendors<<$x>>";' ===SORRY!=== Unable to parse expression in double quotes; couldn't find final '"' (corresponding starter was at line 1) at -e:1 --> >" ~ "\t" ~ "%Vendors<<$x>>";⏏ expecting any of: double quotes postfix Other potential difficulties: Ambiguous use of >>; use » instead to mean hyper, or insert whitespace before >> to mean a quote terminator (or use different delimiters?) at -e:1 --> 2" } ); say "%Vendors<<$x>>⏏" ~ "\t" ~ "%Vendors<<$x>>"; Ambiguous use of >>; use » instead to mean hyper, or insert whitespace before >> to mean a quote terminator (or use different delimiters?) at -e:1 --> me>" ~ "\t" ~ "%Vendors<<$x>>⏏"; I got it finally. I had to switch from a one liner to an actual program #! /usr/bin/env perl6 my $x = "Ace"; my %Vendors = ( "acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => "A102" } ); print( %Vendors<< $x >> ~ "\t" ~ %Vendors<< $x >> ~ "\n" ); $ HashOfHashTest.pl6 Mo A102 And it demanded a white space in << $x >> And as Bruce pointed out, it should the %Vendors{$x}
Re: I need hash inside a hash help
That may work, but is bad practice. Instead of: %Vendors<< $x >> , please use: %Vendors{$x} The relation of `<<…>>` is to `<…>` as double-quotes are to single-quotes; doubling up changes from non-interpolating to interpolating. To say `%Vendors<< $x >>` is to take the shortcut intended for constant keys, and bludgeon it to make it support variable keys, when the basic (and shorter) syntax of `%Vendors{$x}` handles the variable key naturally. — Hope this helps, Bruce Gray (Util of PerlMonks) > On Jan 11, 2019, at 1:50 PM, ToddAndMargo via perl6-users > wrote: > > On 1/11/19 11:43 AM, ToddAndMargo via perl6-users wrote: >> On 1/11/19 11:39 AM, ToddAndMargo via perl6-users wrote: >>> On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers >>> >>> Yup. I am on fire today! :'( >>> >>> Still can't get it figured out. :'( :'( >>> >>> $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", >>> "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => >>> "A102" } ); say "%Vendors<$x>" ~ "\t" ~ >>> "%Vendors<$x>";' >>> Use of uninitialized value of type Any in string context. >>> >>> >>> $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", >>> "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => >>> "A102" } ); say "%Vendors<"$x">" ~ "\t" ~ >>> "%Vendors<"$x">";' >>> Use of uninitialized value of type Any in string context. >>> >>> $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", >>> "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => >>> "A102" } ); say "%Vendors<{$x}>" ~ "\t" ~ >>> "%Vendors<{$x}>";' >>> Use of uninitialized value of type Any in string context. >>> >>> $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", >>> "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => >>> "A102" } ); say "%Vendors<{"$x"}>" ~ "\t" ~ >>> "%Vendors<{"$x"}>";' >>> Use of uninitialized value of type Any in string context. >>> >>> >>> I can't win. >> $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", >> "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" => >> "A102" } ); say "%Vendors<<$x>>" ~ "\t" ~ >> "%Vendors<<$x>>";' >> ===SORRY!=== >> Unable to parse expression in double quotes; couldn't find final '"' >> (corresponding starter was at line 1) >> at -e:1 >> --> >" ~ "\t" ~ "%Vendors<<$x>>";⏏ >> expecting any of: >> double quotes >> postfix >> Other potential difficulties: >> Ambiguous use of >>; use » instead to mean hyper, or insert whitespace >> before >> to mean a quote terminator (or use different delimiters?) >> at -e:1 >> --> 2" } ); say "%Vendors<<$x>>⏏" ~ "\t" ~ >> "%Vendors<<$x>>"; >> Ambiguous use of >>; use » instead to mean hyper, or insert whitespace >> before >> to mean a quote terminator (or use different delimiters?) >> at -e:1 >> --> me>" ~ "\t" ~ "%Vendors<<$x>>⏏"; > > > I got it finally. I had to switch from a one liner to an actual program > > > > #! /usr/bin/env perl6 > > my $x = "Ace"; > my %Vendors = ( "acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, >"Ace" => { "ContactName" => "Mo","AccountNo" => "A102" } > ); > > print( %Vendors<< $x >> ~ "\t" ~ %Vendors<< $x >> ~ > "\n" ); > > > > $ HashOfHashTest.pl6 > MoA102 > > And it demanded a white space in << $x >>
Re: I need hash inside a hash help
On 1/11/19 11:59 AM, Bruce Gray wrote: That may work, but is bad practice. no fooling! look like hell too
subnet calculator
Hi All, Anyone know if someone has written a program like this in Perl that will run locally and not require the Internet? http://www.subnet-calculator.com/ Many thanks, -T
Re: subnet calculator
http://jodies.de/ipcalc Download link at bottom of page. On Fri, Jan 11, 2019 at 3:08 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > Anyone know if someone has written a program like this > in Perl that will run locally and not require the Internet? > > http://www.subnet-calculator.com/ > > > Many thanks, > -T > -- __ :(){ :|:& };:
Re: subnet calculator
> On Jan 11, 2019, at 2:07 PM, ToddAndMargo via perl6-users > wrote: > > Hi All, > > Anyone know if someone has written a program like this > in Perl that will run locally and not require the Internet? > > http://www.subnet-calculator.com/ > > > Many thanks, > -T I have not used it, but this looks to be equivalent : https://blog.mypapit.net/2005/06/perl-ip-subnet-calculator.html http://jodies.de/ipcalc-archive/ipcalc-0.41/
Re: subnet calculator
On Fri, Jan 11, 2019 at 3:08 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Hi All, Anyone know if someone has written a program like this in Perl that will run locally and not require the Internet? http://www.subnet-calculator.com/ Many thanks, -T On 1/11/19 1:55 PM, Paul Procacci wrote: http://jodies.de/ipcalc Download link at bottom of page. Thank you! H. Perl 5.
Re: subnet calculator
On 1/11/19 1:56 PM, Bruce Gray wrote: On Jan 11, 2019, at 2:07 PM, ToddAndMargo via perl6-users wrote: Hi All, Anyone know if someone has written a program like this in Perl that will run locally and not require the Internet? http://www.subnet-calculator.com/ Many thanks, -T I have not used it, but this looks to be equivalent : https://blog.mypapit.net/2005/06/perl-ip-subnet-calculator.html http://jodies.de/ipcalc-archive/ipcalc-0.41/ Thank you!
I need hash string help
Hi All, Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors; say $y;' Type check failed in assignment to $y; expected Str but got Any (Any) in block at -e line 1 $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors.Str; say $y;' Use of uninitialized value of type Any in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in block at -e line 1 Many thanks, -T
POD: linking to a module
Hello, How do I properly write a link to a module in a POD documentation? Actually, the question is even more complex as it might be both a module and a .pod. The documentation (https://docs.perl6.org/language/pod) isn't clear on this subject. When it comes to `L<>` docs are mostly focused on URL or intra-page links. Well, of course I can pre-generate .md and link to a github page. But hoping that at some point the modules site will gain functionality similar to metacpan and will be able to display embedded PODs as pages I'd like to keep this in mind and do things correctly from the start. Besides, by linking to github I would also have to always keep in mind updating links to have them pointing at the correct module version which might be problematic with a big number of links. BTW, neither I found a way to generate different content for different output formats. Best regards, Vadim Belman
Re: I need hash string help
On Fri, Jan 11, 2019 at 19:09 ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Now what am I doing wrong? I need to convert the value in a > hash to a string: > > $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => > "Larry" ); Try eliminating “acme =>” for a starter. -Tom
Re: I need hash string help
On 1/11/19 5:08 PM, ToddAndMargo via perl6-users wrote: Hi All, Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors; say $y;' Type check failed in assignment to $y; expected Str but got Any (Any) in block at -e line 1 $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors.Str; say $y;' Use of uninitialized value of type Any in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in block at -e line 1 Many thanks, -T Figured out my booboo. I had to change from $PartsStr = "Hi $Manager," ~ "Account Number: $AccountNo" ~ to $PartsStr = "Hi " ~ $Manager ~ "," ~ "Account Number: " ~ $AccountNo ~ "" ~
Re: I need hash string help
On 1/11/19 5:59 PM, Tom Browder wrote: On Fri, Jan 11, 2019 at 19:09 ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); Try eliminating “acme =>” for a starter. -Tom Hi Tom, It was a shortened version of a lager has within a hash. $ p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 } ); say %Vendors{$x} ~ "\t" ~ %Vendors{$x};' $p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 } ); my Str $y = %Vendors{$x}.Str; say $y;' I just shortened it to test syntax. I need the value of the hash to going into a string. It did but the error message I got back confused the heck out of me. Type Str does not support associative indexing. Made me think something was wrong with the hash. The hash and was fine. I found it by disregarding the error message and looking for ANYTHING I had changed. My error turned out be `$var` (HTML "Break") being mistaken for something else in a string assignment. Breaking the variables apart with `$var ~ ""` fixed it. Thank you for the help anyway. There is a lot of great folks on this list. :-) -T -- ~~ Computers are like air conditioners. They malfunction when you open windows ~~
Re: I need hash string help
On Fri, Jan 11, 2019 at 20:15 ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: ... > $p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry", > AccountNo => 1234 } ); my Str $y = %Vendors{$x}.Str; say $y;' In my experience, it helps often to avoid using strict typing unless really needed. Best regards, -Tom
Re: I need hash string help
> On Jan 11, 2019, at 7:08 PM, ToddAndMargo via perl6-users > wrote: > > Hi All, > > Now what am I doing wrong? I need to convert the value in a > hash to a string: > > $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => > "Larry" ); $y= %Vendors; say $y;' > $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => > "Larry" ); $y= %Vendors.Str; say $y;’ —snip— This has nothing to do with string conversion. Compared to the previous email thread, two problems have been introduced: 1. The curly braces from around the second-level hash are now missing, changing from CompanyName => { SomeKey => "foo" ... } to CompanyName => SomeKey => "foo" ... So, you no longer have a HashOfHashes, you have a HashOfPair (singular Pair, not plural Pairs), so while this syntax can technically be made to work, it would only work with a single key, which is pointless. 2. The first level (company name?) of your HashOfHashes is no longer dereferenced. I see that you populated `$x`, but did not ever use it. %Vendors{"acme"}; # Correct %Vendors{$company};# Correct, if $company contains `acme` %Vendors;# Correct and most Perlish, if company is constant %Vendors; # Bad; will never work unless you happen to have a company really named "ContactName”. (Even then, you would get the whole first-level hash) UPDATE: Just before sending this, I peeked ahead at the exchange between Tom Browder and yourself. I think that you hit a snag, and constructed an example that showed what you thought was the snag, but was really a new set of problems that exists only in your example. FYI, every time that I have made this mistake, it was always due to my creating an example from scratch, instead of slowly massaging the real problem code down into a minimal form for public discussion. YMMV. I am glad you and Tom resolved your problem before I could `send`, but I did not want this post to go to waste. — Hope this helps, Bruce Gray (Util of PerlMonks)
Re: I need hash string help
On 1/11/19 6:23 PM, Tom Browder wrote: On Fri, Jan 11, 2019 at 20:15 ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: ... > $p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry", > AccountNo => 1234 } ); my Str $y = %Vendors{$x}.Str; say $y;' In my experience, it helps often to avoid using strict typing unless really needed. Best regards, -Tom There are instances where I get myself in a mess if I do not type things. So some I do and some I don't. Keeps me out of trouble. Most times now I do. One instance where I fly back and forth between strings and integers is where I am checking revisions. Is "12.3.4.1" newer than "111.3.4.1"? I do a split on the variable at the dots, turn the string fragments into integers and test each position one at a time. The code was a nightmare until I started using typing. That found all my mistakes with alacrity. Code came out real elegant after that. I was pleased with my ingenuity. I use .Str and .Int a lot now-a-days too. Even if not necessary, it is for maintainability when there is a conversion going on that I have forgotten about. In the question I posted the value had to absolutely be a Str and nothing else. If anyone added to it and was not properly turning other things into a string, I wanted it to instantly fail. The Str in question was a HTML that was passing a parts order to Thunderbird to mail to my vendors.
Re: I need hash string help
$a is short for $a{'a','b'} This also happens in string literals my $a = { a => 1, b => 2 }; say "$a"; # 1 2 say "$a{'a','b'}"; # 1 2 A simple way to stop this is to add a backslash my $a = 'b' say "$a\"; # b You can also call methods on variables in string literals, as long as you use parentheses. my $a = Date.today; say "$a.year()-$a.month()-$a.day()"; # 2019-1-11 (Note that Date has a .-mm-dd() method) --- Looking at the message you just added: Perl 6 has a Version type. my $a = Version.new("12.3.4.1"); my $b = Version.new("111.3.4.1"); say $a before $b; # True Also there is syntax for creating a Version literal my $a = v12.3.4.1; my $b = v111.3.4.1; say $a before $b; # True There are useful methods on Versions my $a = v12.3.4.1; say $a.parts.perl; # (12, 3, 4, 1) On Fri, Jan 11, 2019 at 8:12 PM ToddAndMargo via perl6-users wrote: > > On 1/11/19 5:08 PM, ToddAndMargo via perl6-users wrote: > > Hi All, > > > > Now what am I doing wrong? I need to convert the value in a > > hash to a string: > > > > $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => > > "Larry" ); $y= %Vendors; say $y;' > > Type check failed in assignment to $y; expected Str but got Any (Any) > >in block at -e line 1 > > > > > > $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => > > "Larry" ); $y= %Vendors.Str; say $y;' > > Use of uninitialized value of type Any in string context. > > Methods .^name, .perl, .gist, or .say can be used to stringify it to > > something meaningful. > >in block at -e line 1 > > > > > > Many thanks, > > -T > > Figured out my booboo. I had to change from > > $PartsStr = >"Hi $Manager," ~ >"Account Number: $AccountNo" ~ > > to > > $PartsStr = >"Hi " ~ $Manager ~ "," ~ >"Account Number: " ~ $AccountNo ~ "" ~
Re: I need hash string help
On 1/11/19 6:35 PM, Bruce Gray wrote: On Jan 11, 2019, at 7:08 PM, ToddAndMargo via perl6-users wrote: Hi All, Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors; say $y;' $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors.Str; say $y;’ —snip— This has nothing to do with string conversion. Compared to the previous email thread, two problems have been introduced: 1. The curly braces from around the second-level hash are now missing, changing from CompanyName => { SomeKey => "foo" ... } to CompanyName => SomeKey => "foo" ... So, you no longer have a HashOfHashes, you have a HashOfPair (singular Pair, not plural Pairs), so while this syntax can technically be made to work, it would only work with a single key, which is pointless. 2. The first level (company name?) of your HashOfHashes is no longer dereferenced. I see that you populated `$x`, but did not ever use it. %Vendors{"acme"}; # Correct %Vendors{$company}; # Correct, if $company contains `acme` %Vendors;# Correct and most Perlish, if company is constant %Vendors;# Bad; will never work unless you happen to have a company really named "ContactName”. (Even then, you would get the whole first-level hash) UPDATE: Just before sending this, I peeked ahead at the exchange between Tom Browder and yourself. I think that you hit a snag, and constructed an example that showed what you thought was the snag, but was really a new set of problems that exists only in your example. FYI, every time that I have made this mistake, it was always due to my creating an example from scratch, instead of slowly massaging the real problem code down into a minimal form for public discussion. YMMV. I am glad you and Tom resolved your problem before I could `send`, but I did not want this post to go to waste. — Hope this helps, Bruce Gray (Util of PerlMonks) That is exactly what happened. What is happening is that I am copy and pasting five columns (and any number of rows) from my parts database to the clipboard, reading the clipboard into my perl code, writing an letter in HTML to my vendor with the parts to be ordered, and then sending it back to the clipboard for pasting into Thunderbird. Each parts group (four lines and a blank line) has an alternate color. Quantities greater than one are bolded. (I haven't had them goof the quantity since I bolded greater than 1.) My company account number is at the top and bolded. The letter includes my salesman's name. Enough HTML to make you scream. I should use single quote when writing in HTML. That would force me to separate variables with ~ I have had them goof my account number. They don't like to ask for my account number as we are suppose to be good buddies and they are suppose to know me by heart. Ha! So now I have included my account number as well. By the way, if anyone is interested, when reading columns from a spreadsheet off the clipboard, the columns are delimited by a tab `\t`
Re: I need hash string help
On 1/11/19 6:49 PM, Brad Gilbert wrote: $a is short for $a{'a','b'} This also happens in string literals my $a = { a => 1, b => 2 }; say "$a"; # 1 2 say "$a{'a','b'}"; # 1 2 A simple way to stop this is to add a backslash my $a = 'b' say "$a\"; # b You can also call methods on variables in string literals, as long as you use parentheses. my $a = Date.today; say "$a.year()-$a.month()-$a.day()"; # 2019-1-11 (Note that Date has a .-mm-dd() method) --- Looking at the message you just added: Perl 6 has a Version type. my $a = Version.new("12.3.4.1"); my $b = Version.new("111.3.4.1"); say $a before $b; # True Also there is syntax for creating a Version literal my $a = v12.3.4.1; my $b = v111.3.4.1; say $a before $b; # True There are useful methods on Versions my $a = v12.3.4.1; say $a.parts.perl; # (12, 3, 4, 1) On Fri, Jan 11, 2019 at 8:12 PM ToddAndMargo via perl6-users wrote: On 1/11/19 5:08 PM, ToddAndMargo via perl6-users wrote: Hi All, Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors; say $y;' Type check failed in assignment to $y; expected Str but got Any (Any) in block at -e line 1 $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors.Str; say $y;' Use of uninitialized value of type Any in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in block at -e line 1 Many thanks, -T Figured out my booboo. I had to change from $PartsStr = "Hi $Manager," ~ "Account Number: $AccountNo" ~ to $PartsStr = "Hi " ~ $Manager ~ "," ~ "Account Number: " ~ $AccountNo ~ "" ~ Thank you!
Re: I need hash string help
On 1/11/19 6:51 PM, ToddAndMargo via perl6-users wrote: On 1/11/19 6:49 PM, Brad Gilbert wrote: $a is short for $a{'a','b'} This also happens in string literals my $a = { a => 1, b => 2 }; say "$a"; # 1 2 say "$a{'a','b'}"; # 1 2 A simple way to stop this is to add a backslash my $a = 'b' say "$a\"; # b You can also call methods on variables in string literals, as long as you use parentheses. my $a = Date.today; say "$a.year()-$a.month()-$a.day()"; # 2019-1-11 (Note that Date has a .-mm-dd() method) --- Looking at the message you just added: Perl 6 has a Version type. my $a = Version.new("12.3.4.1"); my $b = Version.new("111.3.4.1"); say $a before $b; # True Also there is syntax for creating a Version literal my $a = v12.3.4.1; my $b = v111.3.4.1; say $a before $b; # True There are useful methods on Versions my $a = v12.3.4.1; say $a.parts.perl; # (12, 3, 4, 1) On Fri, Jan 11, 2019 at 8:12 PM ToddAndMargo via perl6-users wrote: On 1/11/19 5:08 PM, ToddAndMargo via perl6-users wrote: Hi All, Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors; say $y;' Type check failed in assignment to $y; expected Str but got Any (Any) in block at -e line 1 $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors.Str; say $y;' Use of uninitialized value of type Any in string context. Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful. in block at -e line 1 Many thanks, -T Figured out my booboo. I had to change from $PartsStr = "Hi $Manager," ~ "Account Number: $AccountNo" ~ to $PartsStr = "Hi " ~ $Manager ~ "," ~ "Account Number: " ~ $AccountNo ~ "" ~ Thank you! Come to think of it, I should have known better. I have these proofing line all over the place: PrintGreenErr( "WebPage = <<<" ~ $WebPage ~ ">>>\n" ); I need to start using single quotes with writing HTML. That way I will be forces to use ~ to add variables to the text.
Re: POD: linking to a module
Actually, we had that functionality, but it was recently eliminated by Richard Hainsworth since, as a matter of fact, there are no specs on what to actually do with them. And it was eliminated for several reasons, one of which is that MetaCPAN does not display Pod6, but the main reason is that there's no canonical place for module documentation. Some of them are in docs.perl6.org (core modules), some of them in github, some in gitlab... Any suggestion is welcome, meanwhile. El sáb., 12 ene. 2019 a las 2:22, Vadim Belman () escribió: > Hello, > > How do I properly write a link to a module in a POD documentation? > Actually, the question is even more complex as it might be both a module > and a .pod. > > The documentation (https://docs.perl6.org/language/pod) isn't clear on > this subject. When it comes to `L<>` docs are mostly focused on URL or > intra-page links. Well, of course I can pre-generate .md and link to a > github page. But hoping that at some point the modules site will gain > functionality similar to metacpan and will be able to display embedded PODs > as pages I'd like to keep this in mind and do things correctly from the > start. Besides, by linking to github I would also have to always keep in > mind updating links to have them pointing at the correct module version > which might be problematic with a big number of links. > > BTW, neither I found a way to generate different content for different > output formats. > > Best regards, > Vadim Belman > -- JJ