Maybe you can use this example as a base:
#!/usr/bin/perl
use warnings;
use strict;
# by jdporter of perlmonks, converts a dir tree to xml
use File::Find;
use XML::Simple;
#my $root = shift or die "Usage: $0 rootdir\n";
my $root = shift || '.';
my %tree;
find(
sub
{ #print "$File::Find::name\n";
my @path = split m,/,, $File::Find::name;
my $tree = \%tree;
$tree = (($tree->{'dir'} ||= {})->{shift @path} ||= {})
while @path > ( -d _ ? 0 : 1 ); @path and # it's a file
push @{ $tree->{'file'} ||= [] }, shift @path; },
$root );
print XMLout( \%tree );