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;
}