use strict; use XML::Twig; my $twig = new XML::Twig(TwigHandlers=> {NBA=>\&NBA}); $twig ->parsefile('nba.xml'); exit

sub nba { my ($twig, $nba)=@_; $nba{stadium}= join ':', map {$_->text || ''}@{[$nba->children( 'Stadium')]; print "$nba(stadium)\n"; $nba ->delete; }