Perl: moved XML access code into a module

This makes it a lot easier to reuse the file access code in multiple scripts