my %hash; my @topkeys = qw/a b c/; my @innerkeys = qw/1 2/; my @values = qw/5.5 3.2 15.0 -22 .02 .15/; for my $k ( @topkeys ) { for my $i ( @innerkeys ) { $hash{$k}{$i} = shift @values; } } print join "\t", (map { sprintf("%.1f",$hash{$_}{1}) } qw/a b c/), "\n"; # or, if "map" is too tough for the inexperienced: printf( "%.1f\t", $hash{$_}{1} ) for ( qw/a b c/ ); print "\n";