my $twig= new XML::Twig( twig_handlers => # player will be called { player => \&player } # when each player element ); # has been parsed $twig->parsefile( "nba.xml"); # build the twig $twig->flush; # flush the end of the twig sub player { my( $twig, $player)= @_; # handlers params are always # the twig and the element