in reply to take input data as hash from a xml file

Use XML::Simple. From the docs:

use XML::Simple; my $ref = XMLin([<xml file or string>] [, <options>]); my $xml = XMLout($hashref [, <options>]);

so to create the xml from a hash:

my %hash; ... # fill the hash my $xml = XMLout (\%hash);

DWIM is Perl's answer to Gödel