How to work with hash of hashes in Perl?

I want to build a struct in Perl that has a hash and a variable,then create a hash that each field will contain the struct I created. like this:

use Class::Struct;

struct exmpl => {hash=>'%' , val => '$'}; 
my %hash_of_structs;
$hash_of_structs { "one" } = exmpl -> new ();

Now hash_of_structs has a field with "one" key that contains the struct exmpl. My question is how do I push new values into the hash that is inside the struct?

I figured how to work with the value in the struct:

$hash_of_structs { "one" } -> val ("1");
printf ( "The value is: %d\n",$hash_of_structs { "one" }-> val );

But it's not working the same way with the hash in the struct. I tried:

$hash_of_structs { "one" } => hash{"uno"}("1");

Thanks :)

Answers


Use the following syntax. If a hash reference is passed, the old content is forgotten, if you supply two arguments, a key - value pair is added.

$hash_of_structs{one}->hash({'A', 'a', 'B', 'b'});
$hash_of_structs{one}->hash('key', 'value');

Need Your Help

EF6 Fluent API Mapping to a compound key

asp.net-mvc entity-framework-5

In the following Code I am trying to tell Code First that SupplyPointServiceSubscriptions will hold 2 foreign keys. One to SupplyPoint and one to SupplyPointService.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.