
Tejas
User
Feb 21, 2017, 7:16 AM
Post #1 of 5
(1965 views)
|
Why am i getting the error Can't use string ("") as a HASH ref
|
Can't Post
|
|
Hi Below is the code i have implemented and it initially works fine and during the run time it throws the error due to else statement Can't use string ("") as a HASH ref while "strict refs" package MyPack::Alerts; sub new { my ($class, $args) = @_; my $self = { # empty array of error strings # empty hash of the endpoints that have had BEM alerts sent endpoints => {}, alert_id => 0, }; sub myfunc { if (! exists $self->{endpoints}->{$anEndpointName}) { ++$self->{alert_id}; $self->{endpoints}->{$anEndpointName}->{alertString} = $anAlertString; $self->{endpoints}->{$anEndpointName}->{alertID} = $self->{alert_id}; } else { $self->{endpoints}->{$anEndpointName}->{alertString} = $anAlertString; } } Why am i getting the below error, whats wroing with the code, Am i missing something ? Thanks Tejas
|