Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Text Columns

by TheDamian (Priest)
on Nov 28, 2006 at 23:02 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://586590]
[Corion]: ambrus: Hurr - yes, that might happen, as Prima will queue lots of stuff (Well, Windows will)
[Corion]: But I'm really amazed that it just took this little code (plus the idle handler I have in mind and something else dk suggested)
[Corion]: ambrus: I wrote the handler so that it stops the timer if it's supposed to be a one-shot
[Discipulus]: are you using Prima Corion? good morning Corion and ambrus, btw

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2016-12-09 09:08 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (150 votes). Check out past polls.