in reply to Using an undefined value as a hashref

The correct usage is:
#!/usr/bin/perl -w use Data::Dumper; { my $hashref = {'foo' => "bar"}; print Dumper($hashref); }
Refer to my for more details.

Replies are listed 'Best First'.
Re^2: Using an undefined value as a hashref
by talexb (Chancellor) on Sep 09, 2005 at 21:10 UTC

    Thanks, but that's not my point.

    I'm trying to assign a value to an element of a hash, and I want to pass around a hashref. So I really do want to set the foo element of hashref to the value bar. And Perl will let me do that if I predeclare the hashref and then set the value, but I can't do it all in one shot.

    I didn't realize that, and spent some time trying to track down the problem -- so now I'd like to understand what part of Perl syntax I misunderstand. Or what black hole I just fell into.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds