Say I have a hashref constant, as shown below:
use constant DOGS => { Lassie => 'collie', Benji => 'mutt', Scooby => 'great dane', Goofy => '???' };
How can I dereference it correctly to say ... are they the keys to it?
warn ref DOGS; # HASH at untitled line 12. warn keys( %{DOGS} ); # Warning: something wrong (empty list) warn keys( DOGS ); # Type of arg 1 to keys must be hash (not constant item)
The following is the only way to make it work:
my $dogs = DOGS; warn keys( %$dogs );
What am I doing wrong?
source share