http://www.perlmonks.org?node_id=139059

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

I am rewriting some of my old one-liners that grew into oft-used utilities. Whilst doing so, I wanted to move a lot of hard-coded strings (pathnames and such) into constants at the top of the script (via the constant pragma). So, I type:
use constant CONST => { foo => 'bar', fiz => 'baz' }; foreach (keys CONST) { print "$_\n"; }
This, of course, returned the error:
Type of arg 1 to keys must be hash (not constant item)
"Owe," I thought, and I changed it to:
foreach (keys %{CONST}) { print "$_\n"; }
This resulted in the error:
Variable "%CONST" is not imported
Hmmmmmm....print CONST; printed HASH(0x1a9de10), which is what I expected. What I did not expect is that I could not access it.

Can someone please enlighten me? In the meantime, I guess I'll try various dereferencing combinations and read up on constant and perlref.

Thanks,
Jeremy