http://www.perlmonks.org?node_id=1009492


in reply to Re^5: looping logic error while printing output from folder/flie content
in thread looping logic error while printing output from folder/flie content

The code I posted above is one way to handle variation in the directory structure. You might need to tweak it to get the kind of xml layout that you want.