<p>Is there any way to use a constant as a hash key?</p>

<p>For example:</p>

<pre><code>use constant X =&gt; 1;

my %x = (X =&gt; 'X');
</code></pre>

<p>The above code will create a hash with "X" as key and not 1 as key. Whereas, I want to use the value of constant X as key.</p>

```
use constant
```
actually makes constant subroutines.
To do what you want, you need to explicitly call the sub:
```
```
use constant X => 1;

my %x = ( &X => 'X');
```
```
or
```
```
use constant X => 1;

my %x = ( X() => 'X');
```
```