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">>;'

Reply via email to