Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Text Columns

by TheDamian (Vicar)
on Nov 28, 2006 at 23:02 UTC ( [id://586590]=note: print w/replies, xml ) Need Help??


in reply to Text Columns

Perl 6 formats aren't like Perl 5 formats. They're much more dynamic. And available in Perl 5. Try this:
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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://586590]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2025-05-21 02:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.