This is a really simple sub that I use to make messages stand out to users in console programs. I learned that our sales reps practically need a hand to come out of the computer and slap them to get their attention. Since I can't code that, this will have to do... 8) Something similar to this has probably been posted before but just in case here it is. Note: This only is for strings 2 chars smaller than your screen width or smaller. If longer strings are needed then you could add something to split the strings at the nearest word boundary below that limit. Anyone care to add that?
use strict; sub emphasize() { # Takes a string and prints it to screen surrounded by astericks f +or emphasis my $screen_width = 80; my $printable_space = ($screen_width - 2); my $string = shift; my $string_length = length($string); if ( ($string_length % 2) != 0 ) { $string .= " "; } print "*" x $screen_width; print "*"; print " " x $printable_space; print "*"; print "*"; print " " x (($printable_space - $string_length) / 2); print "$string"; print " " x (($printable_space - $string_length) / 2); print "*"; print "*"; print " " x $printable_space; print "*"; print "*" x $screen_width; }

In reply to Emphasize a string by Anonymous Monk

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.