Whats important to note is that the warning comes with a line number, which you can use to investigate (it should give away which variable caused it)
As I said in my orginal post I suspect there is action-at-a-distance going on. The real culprit is in one place but the bug is manifesting with respect to another variable that's getting accidently aliased.
When I run the code (which is in a module) in a standalone CGI script it doesn't give warnings. When I run the code under Apache::Registry then it starts giving warnings in many unrealated places after a few transactions.
Here is an example of one of the places where it's giving a warning.
for my $field ( @$self{@{$_{FIELDS}}} ) {
$field->set_related(AFTER => \@keys );
$field->{MULTI} = 1 if $_{MULTICODE} && ! exists $field->{MUL
+TI};
$field->{ORDERED} = 1 if $_{ORDER} && ! exists $field->{ORDERE
+D};
$field->{CONTEXT_KEYS} = $_{CONTEXT_KEYS} if $_{CONTEXT_KEYS}
+&&
! exists $field->{CONTEXT_KEYS};
if ( $table ) {
$field->{TABLE} = $table unless exists $field->{TABLE};
$field->{COLUMN} = $fieldmap->{$field} || "$field"
unless exists $field->{COLUMN};
}
}
if ( $structured_field ) { # Warning here!
$fieldmap = {%$fieldmap};
my @pseudo_fields = map { @$_ } values %$structured_field;
@$fieldmap{@pseudo_fields} = map { [ $fieldmap->{$_} || $_ ] }
+ @pseudo_fields;
}
As you see the line where the warning appears has no buisness unreferencing any scalars. The variable $structured_field is, by the way, undef.
The perhaps interesting thing is that the variables $self and $field are not a blessed hashes but rather are objects that overload '%{}'. Furthermore the '%{}' overload on $self is done via a transitory tied hash...
use overload
'%{}' => sub { my $self = shift; tie my(%h), $self; \%h };
sub TIEHASH { shift }
UPDATE Replacing the transitory tied hash with a persistant one did not fix the problem. |