in reply to Anonymous Scalar Ref to Hash?

That's an interesting situation. A possible solution would be to let your subclass have its own private table of instances, and use the scalar reference as a key to that table, as such:
package MyDoc; @ISA = qw(XML::LibXML::Document); my %instance_hashes; sub new { my $class = shift; my $self = $class->SUPER::new('1.0', 'UTF8'); my @listeners = (); # initialize private hash data $instance_hashes{$self} = {}; $self->listener(\@listeners); bless $self, $class; } # accessor / mutator sub listener { my $self = shift; if (@_) { $instance_hashes{$self}{Listeners} = shift; } return $instance_hashes{$self}{Listeners}; }
Here we use the $self reference as the key to %instance_hashes, where we can store info about each instance.

BTW, please use <code></code> tags in your posts. Also, I changed the line where you set the Listeners to @listeners. The way you had it (in scalar context), it would initialize $self->{Listeners} to the size of @listeners, not the elements of the list. Use a reference to the @listeners array to allow access to it from other methods, which is probably what you had in mind.

blokhead