Can't call method "set_att" without a package or object reference at mine.pl line 40, chunk 2. #### #!/usr/bin/perl -w use strict; use XML::Twig; $/="\n\n"; my $doc = ; # the original data set my $expected_doc = ; # result with elements changed to attributes my $twig= new XML::Twig( # create the twig pretty_print => 'indented', twig_roots => { 'elt_att' => sub { addAtt(@_,'elt') }, 'selt_att' => sub { addAtt(@_,'subelt') }, }, ); $twig->parse($doc); $twig->flush; # Finished. exit(0); # Give a decent error message if we wrote to stdout and had disk full. END { close(STDOUT) || die "ERROR: can't close stdout: $!\n" } #=============================================================================== # Subroutines #------------------------------------------------------------------------------- sub addAtt { my( $t, $att,$parent)= @_; my $e_parent = $t->findnodes($parent); $e_parent->set_att($att->gi,$att->trimmed_text); $att->delete; $t->flush; } __DATA__