in reply to Re: Add Data to Hash Reference
in thread Add Data to Hash Reference

So, if I want to construct the data structure in my example, how should I write it?

Replies are listed 'Best First'.
Re^3: Add Data to Hash Reference
by moritz (Cardinal) on Dec 07, 2010 at 20:35 UTC

    How about

    my $test = { 'record' => { 'a' => 11, 'b' => 22 } };

    Or just:

    my $test; $test->{record}->{'a'} = 11; $test->{record}->{'b'} = 22;

    If you want to initialize $test->{record} with something (and don't rely on autovivification), initialize it with {}.