use strict; use XML::Generator; my $attribute_name = 'book'; my $value = 'value'; my $attribute_value = 'Camel book'; my $xml_handle = XML::Generator->new( pretty => 4 ); print $xml_handle->$attribute_name($xml_handle->$value($attribute_value)); print "\n"; exit(0);