my @list = (); my $parser = XML::LibXML->new(); sub Process($) { my $f = shift; if (-f $f and -r $f) { if (scalar(grep($_ eq $f, @list)) == 0) { push @list, $f; my $root = $parser->parse_file($f)->documentElement(); my $prefix = $root->lookupNamespacePrefix('http://www.w3.org/2001/XInclude'); if ($prefix) { my $ok = 1; foreach my $xincludeNode ($root->getElementsByTagName("$prefix:include")) { my $xincludeFilename = File::Spec->rel2abs($xincludeNode->getAttribute('href')); $ok &&= Process($xincludeFilename); } return $ok; } else { return 1; } } else { return 1; } } else { print STDERR "The file '$f' isn't found or not readable\n"; return 0; } } Process(File::Spec->rel2abs($ARGV[0])); my $list = join("\n", @list); print $list, "\n";