I have pieve of code that I am trying to assign the return value but I see the following error. Appreciate if someone can let me know why am I getting this error.
Error: Not a HASH reference at line
sub getid {
my ($a, $b) = @_;
my $id = 1 << $a + 1 << $b;
return $id;
}
my $tip;
$tip->{'tock'}->[0]->{'brick'} = getid(2, 3); <== This is where I am having issue.
That's not the code you actually ran to get that error. In your actual code, $tip or $tip->{'tock'}->[0] is defined but doesn't hold a reference to a hash. Print them out to find out which.
It might be useful to dump your data structure to figure out what it actually is.
use Data::Dumper;
print(Dumper($tip));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With