Struggling with scopes....

Ewen McNeill ewen at
Sun Dec 22 01:35:25 CST 2002

In message <0rna0vkgf3r9aenpf0s05im518t386lg34 at>, Enkidu writes:
>How do I stash %mindex or a pointer to it in the object hash, and how
>do I access it in the "nearness" subroutine?

Assuming that your object is a hash (rather than an array), you can
stick a reference to your %mindex hash into it under some suitable name,

$self->{'mindex'} = \%mindex;

And then you can pull it back out with something like:

$mindex_ref = $self->{'mindex'};

And use it as:

print $mindex_ref->{'thingy'};


foreach keys %{$mindex_ref}
  print "Key: $_\n";

Or use it via the self hash directly:

print $self->{'mindex'}->{'thingy'};

Or whatever works for you.

This is "obvious" to me, and you say you couldn't find any obvious
solution to your problem, so perhaps I've misunderstood your problem; if
so feel free to explain some more.


More information about the Wellington-pm mailing list