Sorry, I saw something that I thought worked:
use constant {
SEC => 0,
MIN => 1,
HOUR => 2,
MDAY => 3,
MON => 4,
YEAR => 5,
WDAY => 6,
YDAY => 7,
ISDST => 8,
};
Instead, it's just syntax sugar to declare multiple constants with one use constant statement.
I searched the doc on constant, and didn't see a good example, though
Dereferencing constant references incorrectly (such as using an array subscript on a constant hash reference, or vice versa) will be trapped at compile time.
implies that a hash constant can be created.
Here's how it's done:
use constant Books_I_Own =>
{
"The Wit and Wisdom of Mark Twain" => 1,
"Attack of the Deranged Mutant Killer Monster Snow Goons" => 1,
"Unix Power Tools" => 1,
}
and from the debugger
DB<2> x Books_I_Own
0 HASH(0x1c831b8)
'Attack of the Deranged Mutant Killer Monster Snow Goons' => 1
'The Wit and Wisdom of Mark Twain' => 1
'Unix Power Tools' => 1
...so it is possible to have a constant set, if a hash is a set.
-QM
--
Quantum Mechanics: The dreams stuff is made of
|