views:

45

answers:

1

Hello, with the hash below, I would like the clients array's reference :

my $this = 
{
    'name' => $name, 
    'max_clients' => $max_clients, 
    'clients' => ()
};

I can't do "\$this{'clients'};" to retrieve the reference.

+2  A: 

You cannot store an array as a value in a hash table. You can only store a scalar value such as a reference to an array:

my $this = 
{
    'name' => $name, 
    'max_clients' => $max_clients, 
    'clients' => [],
};

See also perldoc perldsc.

Sinan Ünür
Yeah, you are right, thanks
Sebastian
@Sebastian You can accept a correct answer by clicking on the check mark next to it.
Sinan Ünür