Subject: | Unexpected behaviour when defining a constant with a HASHREF or ARRAYREF value |
If you try and declare a constant with an ARRAY ref value or HASH ref value,
you get unexpected results. For example:
use Scalar::Constant HASHREF => { a => 1, b => 2, c => 3 };
use Scalar::Constant ARRAYREF => [ 1, 2, 3 ];
It appears to have worked, until you then try and dereference the scalar.
The error message you get is confusing, until you realise that because of how the module
works, the hashref and arrayref got interpreted in a string context.
Given how the module works, I think you should check ref() of the constant value,
and croak if it's not a regular scalar value.