Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Neat format and word wrap

by trizen (Hermit)
on Apr 13, 2012 at 14:29 UTC ( #964935=note: print w/replies, xml ) Need Help??

in reply to Neat format and word wrap

use 5.010; use Text::Wrap qw(wrap $columns); our $columns = 57; # change this my $hbar = q{-} x ($columns + 12); # DON'T change this printf "%s\n| TITLE |%-${columns}s| %s\n| AUTHOR |%-${columns}s| %s\n| DATE |%-${columns}s| %s\n| CONTENT |%-${columns}s| %s\n", map({ if (/\n/) { s{^(.*)\K\n} { sprintf("%*s\n|", $columns - length($1), '|'). q{ } x (length($hbar)-$columns-3). q{| } }egm; s{\n\|\h+\|(.*)\K\z} { sprintf '%*s', $columns - length($1), q{ } }e; s{\A(.*)\K\|$}{length($1)<$columns ? q{ |} : q{|}}em; } $_ } map({$hbar, q{ } . wrap(q{}, q{}, $_)} $title, $author, $date, $content),$hbar);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://964935]
[GotToBTru]: that sounds fair to me
[davies]: I've just "approved" using syscalls in perl through inline c for at least the third time, but it still appears to me as unapproved. Is this just me?
[LanX]: erix: other side of the pond
[LanX]: davies: same problem
[Corion]: It had been approved as a Perl Monks Discussion. It should now be approvable into SoPW
[choroba]: Approved
[LanX]: hmm aproval doesn't stick after move? Or was it a race condition

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2017-01-16 15:07 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.