Just replace $VAR1 = 'XX' with number: XX, and so on. You might want to study perlre. But, as was suggested before by Jenda, parsing the whole XML into a data structure should make your code easier to understand and maintain.
Comment on Re: perl script to print data like this in pdf.