#!/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'); for my $ro (@data) { my $row = XML::Twig::Elt->new('tr'); for my $aw ( @{$ro}{ 'age', 'weight' } ) { XML::Twig::Elt->new( 'td', $aw )->paste( 'last_child', $row ); } $row->paste( 'last_child', $table ); } print "
12 | 200 |
22 | 100 |
12 | 200 |
22 | 100 |
12 | 200 |
22 | 100 |
12 | 200 |
22 | 100 |