I kind of described it already, but here's one brainstorm that is untested:

use strict; use warnings; my $string = <<HERE; A long time ago in a galaxy far far away a great adventure took place. HERE sub textbox { my( @lines ) = split /\n/, $_[0]; chomp @lines; my $longest = 0; foreach my $line ( @lines ) { my $size = length $line; $longest = $size if $size > $longest; } foreach my $line ( @lines ) { my $prepad = ' ' x ( ( $longest - length( $line ) ) / 2 ); $line = $prepad . $line; $line .= ' ' x ( $longest - length( $line ) ); $line = '* ' . $line . ' *'; } my $outline = '*' x ( $longest + 4 ); push @lines, $outline; unshift @lines, $outline; return join( "\n", @lines ) . "\n"; } print textbox( $string );

This could use some streamlining, but I left it reasonably verbose so that it would be clear what's going on. Enjoy!


Dave


In reply to Re^3: Special formatting of error messages by davido
in thread Special formatting of error messages by Ronnie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.