#!/usr/bin/perl use strict; use warnings; use constant {KEY_1 => 0, KEY_2 => 1}; my %hash = (KEY_1() => 5, KEY_2, 7); print $hash{KEY_1()}; print @hash{KEY_1, KEY_2};
Note that constants are really subroutines (Thanks for the CB help tye), so trying to access them using $hash{KEY_1} will fail, though you could build in a little resilience by making the value of KEY_1 equal to 'KEY_1'.
In reply to Re: strict and hashrefs
by kennethk
in thread strict and hashrefs
by danmcb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |