develooper Front page | perl.perl6.users | Postings from January 2019

Re: I need hash inside a hash help

Thread Previous | Thread Next
From:
Timo Paulssen
Date:
January 11, 2019 19:09
Subject:
Re: I need hash inside a hash help
Message ID:
57624cb7-90b4-94ac-e70b-c220b375510a@wakelift.de
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

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About