use List::Util qw< max >; my $terminal_cols = 80; # or whatever my $column_gap = 3; # or whatever my @display_items = map { "$_: $hash{$_}" } sort keys %hash; my $max_col_width = max map {length($_) + $column_gap} @display_items; my $column_count = $terminal_cols / $max_col_width; my $formatting = '{:[[{*}[[:}' x $column_count; use Perl6::Form; print form $formatting, (\@display_items) x $column_count;