in reply to Special formatting of error messages
This quick and dirty but a fun brain teaser.
use strict; my @lines = <DATA>; my $maxsize = 0; map {chomp; $maxsize = ($maxsize>length)?($maxsize):(length)} @lines; print "max size: $maxsize\n"; my $bar = '*' x ($maxsize +4) . "\n"; my $format = '%' . $maxsize . '.' . $maxsize . 's'; foreach (@lines) { print($bar); printf("* $format *\n", $_); print($bar); } __DATA__ some lines that are of different sizes Some small really small. ----------------some large--------------------- --------------------------------------------------some huge----------- +--------------------------------------- ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Special formatting of error messages
by Ronnie (Scribe) on Feb 02, 2005 at 11:51 UTC | |
by osunderdog (Deacon) on Feb 02, 2005 at 13:51 UTC | |
by eric256 (Parson) on Feb 02, 2005 at 17:02 UTC | |
by osunderdog (Deacon) on Feb 02, 2005 at 18:07 UTC | |
by Ronnie (Scribe) on Feb 02, 2005 at 15:29 UTC | |
by osunderdog (Deacon) on Feb 02, 2005 at 16:05 UTC |