Wally Hartshorn has asked for the wisdom of the Perl Monks concerning the following question:

Okay, I'm stumped. This works as two lines...:
my $array_ref = $hash_ref->{$object->method}; push @$array_ref, "something";
...but I would like to make it one line to eliminate the pointless $array_ref. Unfortunately, I can't work out the proper syntax. Something like this...
push @($hash_ref->{$object->method}), "something";
...but correct! Can someone help?

Wally Hartshorn

Replies are listed 'Best First'.
Re: Syntax to dereference array_ref in a hash_ref?
by Transient (Hermit) on Jun 08, 2005 at 19:23 UTC
    so close... push @{$hash_ref->{$object->method}}, "somthing"
Re: Syntax to dereference array_ref in a hash_ref?
by Roy Johnson (Monsignor) on Jun 08, 2005 at 20:23 UTC
    Review the 3 ways to dereference. You want to know them by heart. Really.

    Caution: Contents may have been coded under pressure.