#!/usr/bin/perl -w use strict; use XML::Twig; my $t = XML::Twig->new( twig_handlers => { child => \&onChild } ); $t->parse('foo bar'); sub onChild { my ($t, $child) = @_; my $atts = $child->atts; $t->parsefile($atts->{file}); }