There is one peculiar thing about the particular element I want to access. It was added during the second time I added things to this element of the hashref. However, a similar sample program (where I add a set of elements, then later add another set of elements) worked fine.
sub satisfied { my ($self, @body) = @_; if ($debug) { warn sprintf "TESTING @body in satisfied() with self-e: %s", Data::Dumper::Dumper($self->{established}); } for my $prop (@body) { if ($debug) { warn sprintf "prop($prop): %s dr: %s dr2: %s dump: %s", $prop, $self->{established}->{$prop}, $self->{established}->{intro_rec}, Data::Dumper::Dumper($self->{established}); }
TESTING intro_rec comp_org adv_prog theory in satisfied() with self-e: + $VAR1 = \ { 'adv_prog' => '1', 'intro_cs' => '1', 'theory' => '1', 'comp_org' => '1', 'intro_req' => '1' }; Use of uninitialized value in sprintf at blib/lib/AI/Proplog.pm line 7 +0. Use of uninitialized value in sprintf at blib/lib/AI/Proplog.pm line 7 +0. prop(intro_rec): intro_rec dr: dr2: dump: $VAR1 = { 'adv_prog' => '1', 'intro_cs' => '1', 'theory' => '1', 'comp_org' => '1', 'intro_req' => '1' };
package X; use strict; sub printlist { my ($self, @L) = @_; for my $prop (@L) { if ($self->{established}->{$prop}) { warn "$prop established"; } else { warn "$prop NOT established"; } } } my $self = {} ; bless $self, 'X'; my @L = qw(intro_cs comp_org adv_prog theory); my @M = qw(intro_req); $self->{established}->{$_}++ for @L; $self->printlist(@L); $self->{established}->{$_}++ for @M; $self->printlist(@M);
In reply to Accessing 2nd level of hashref is failing by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |