in reply to Building Hashrefs

Hi,

First, perldoc perlref is your friend!
Have a look and your life will be much better.

In your example, the structure $scalar->{} will autovivify (*) an anonymous HASH reference, just as:

my $hash_ref = {}; ${$hash_ref}{foo} = "bar";

(*) More about autovivification: http://tlc.perlarchive.com/articles/perl/ug0002.shtml

Updated: Fixed typos =/

Replies are listed 'Best First'.
Re^2: Building Hashrefs
by pbeckingham (Parson) on Jul 23, 2004 at 14:54 UTC

    You have omitted the sigil on your declaration, and misspelled the variable while dereferencing it for some reason.

    my $hash_ref = {}; $hash_ref->{foo} = "bar";

      Thanks, Fridays are so bad...
      Updated.