my $ary = [ { c1 => 1, c3 => 3 }, { c2 => 2, c3 => 3, c4 => 4 }, { c5 => 5 }, ]; my @cols = qw( c1 c2 c3 c4 c5 ); # to set a vaulue in a col that may or may not exist.... $ary->[0]->{c2} = 2; # print out as a table print join " ", @cols, "\n"; for my $ref( @$ary) { print join " ", (map{ defined $ref->{$_}? $ref->{$_} : '~' }@cols), "\n"; } __DATA__ c1 c2 c3 c4 c5 1 2 3 ~ ~ ~ 2 3 4 ~ ~ ~ ~ ~ 5