my @th = "col1" .. "col3"; my @values = "val1" .. "val6"; my @td; push @td, [ splice @values, 0, scalar @th ] while @values; print "