#!/usr/bin/perl use XML::Simple; my @file; my (@labels) = split /\s+/, ; while () { chomp; my %line; @line{@labels} = split /\t/; push @file, \%line; } print XMLout(\@file); __DATA__ First Last Fred Flintstone Barney Rubble Betty Rubble Wilma Flintstone ####