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

Re: I need hash inside a hash help

Thread Previous | Thread Next
From:
ToddAndMargo via perl6-users
Date:
January 11, 2019 19:12
Subject:
Re: I need hash inside a hash help
Message ID:
e92d96b3-ec26-e9ce-f092-3febc6a04b00@zoho.com
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

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