As others have argued, there is no limit to what is permitted as a hash key. If you use a link, it will be converted to a string.
However, there are times when you do not need quotes and time when you need quotes around your hash key. If you have spaces or non-alphanumeric characters, you need quotes around your hash key. Interestingly, you can use periods if you use only numeric characters. Otherwise, you cannot use periods without quoting around your key:
$hash{23.23.23} = "Legal Hash Key"; $hash{foo.bar} = "Invalid Hash Key"; $hash{"foo.bar"} = "Legal Hash Key because of quotes";
And to find out what happens if you use the link as a key:
#! /usr/bin/env perl use strict; use warnings; use feature qw(say); use Data::Dumper; my %hash; my $ref = [qw(this is an array reference)]; $hash{$ref} = "foobar";
It produces:
DUMP: $VAR1 = { 'ARRAY(0x7f8c80803ed0)' => 'foobar' };
Thus, the array reference was shorthand, that is, it was connected to a string.
Unfortunately, you did not provide the code, so we really cannot say what your error is. You may need to put quotation marks around your hash keys. Or maybe there is another problem.
source share