variables - Deleting key/value pairs from perl result in Global symbol requires explicit package name error -
variables - Deleting key/value pairs from perl result in Global symbol requires explicit package name error -
i trying delete key/value pairs hash, global symbol requires explicit bundle name exception , don't know how debug this. read on solutions, none of them seem work. hash declared in fashion:
my $hash = foo();
then go through hash using line of code:
while (my ($key, $value) = each %$hash)
and in block select values don't want , store keys these values in array declared (before loop of course):
my @keysarray = ();
i access array retrieve keys using code can delete them hash:
for $key (@keysarray){ delete $hash{$key};# line of code causing problem }
the lastly line wrote 1 causing global symbol "%hash" requires explicit bundle name exception.
any fixes or doing wrong here.
p.s. changed variable names , removed other internal code, format same.
help please! thanks.
delete $hash{$key}
deletes entry %hash
. there no %hash
. instead want write delete $hash->{$key}
, deletes entry %$hash
.
i suggest perldoc perlreftut answering of questions references , how utilize them.
perl variables hash cgi
Comments
Post a Comment