use XML::Simple; use strict; use warnings; my ($id, $value); #group 1 paramters $id = "ID1"; $value = "Recording INformation"; getParameter($id, $value); $id = "ID2"; $value = "Pausing INformation Record "; getParameter($id, $value); $value = "Information Loading"; getParameter($id, $value); $value = "Information loading Complete"; #From here group 2 parameter starts my $id = 2; $value = "Picture loading"; getParameter($id, $value); my $id = 3; $value = "Picture loading complete"; getParameter($id, $value); #Group 2 parameters end. sub getParameter { my ( $id,$value) = @_; my $hash = { 'Key' => $id, 'Value' => $value }; my $xml = { Parameter => [] }; push( @{ $xml->{Parameter} } , { key => $hash->{Key}, content => $hash->{Value} } ); print XMLout( $xml, RootName => 'Parameter' ); } #### Recording INformation Pausing INformation Record Information Loading Information loading Complete #### - Some Value Some Value Some Value - Some Value Some Value Some Value