#!/usr/bin/perl -- use strict; use warnings; use XML::Twig; my @data = ( { age => 12, weight => 200 }, { age => 22, weight => 100 } ); my $table = XML::Twig::Elt->new('table'); $table->insert_new_elt( 'last_child' => 'tr' => ( map { $table->new( # XML::Twig::Elt 'td', $_ ) } @{$_}{ 'age', 'weight' } ), ) for @data; $table->print('record_c'); __END__
| 12 | 200 |
| 22 | 100 |