Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
go ahead... be a heretic
 
PerlMonks  

Re: Neat format and word wrap

by trizen (Friar)
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);


Comment on Re: Neat format and word wrap
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-04-17 23:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (459 votes), past polls