package Foo; use strict; use XML::LibXML; use Scalar::Util qw/weaken/; use Data::Dumper; sub DESTROY { my $self=shift; warn "\n$self dtor"; } sub new { warn "\n".__PACKAGE__." xtor"; my $self = {}; bless $self, __PACKAGE__; my $parser = XML::LibXML->new(); my $confdoc = $parser->parse_string(''); my $root = $confdoc->documentElement(); my @nodes = $root->findnodes('/*'); for my $n (@nodes){ for my $att ($n->attributes()) { my $foo = $att->nodeName; my ($key, $val) = (lc($att->nodeName), lc($att->getValue)); warn "$key - $val"; } } warn __PACKAGE__." xtor COMPLETE"; return $self; } package user; sub DESTROY {Foo->new()} bless my $self=[] => __PACKAGE__; my $f=Foo->new();