..
use strict;
use warnings;
...
my (%customer);
%customer = ();
...
17 sub _customer_id {
18 my $customer_r = shift;
19 unless(defined $customer{$customer_r}){
20 $customer{$customer_r} = ++$customer_id;
21 }
22 $customer{$customer_r};
23 }
I'm just checking whether some hash key exists.
But getting the Use of uninitialized value in hash element
at line 19
,20
,22
.
Why?
This error means $customer_r
is undef
.
How are you calling this function?
You may want to check this statement.my $customer_r = shift;
If $customer_r
gets some empty value, then you would get this error when you try to use this variable.
Basically, whenever you try to use an empty variable(not initialised), you would encounter this error.
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