SerriaRomeo wrote:
Ok, this is a very newbie problem,  I'm just not smart enough to
figure out how to do it.

I have text in a file that looks like this.

0 !~
Syntax: !

! repeats the last command you typed.
~

0 "REMOVE INVIS"~
Syntax: cast 'remove invis' <object>

This spell will make an invisible object in the character's inventory
visible.
This is an AGGRESSIVE spell when used on others. I.e, it will attack
another player if you attempt to use it on them.
~

and I want to reformat each section to something like this:

0 !~
 @                                                                  @
 @                                                                  @
|\|========================|\|
|\|                                                                  |
\|
|\| Syntax: !                                                   |\|
|\|                                                                  |
\|
|\| ! repeats the last command you typed.  |\|
|\|                                                                  |
\|
|\|========================|\|
 @                                                                 @
 @                                                                 @
~

each section is blocked off by #command~ and ~ (Blank Line) at the
end.

Is this possible,  if so how would I go about doing it?

This appears to work:

#!/usr/bin/perl
use warnings;
use strict;

my $head = ( ( '@' . ( ' ' x 66 ) . "[EMAIL PROTECTED]" ) x 2 ) . '|\|' . ( '=' x 24 ) . "|\\|\n"; my $tail = '|\|' . ( '=' x 24 ) . "|\\|\n" . ( ( '@' . ( ' ' x 66 ) . "[EMAIL PROTECTED]" ) x 2 );
my $format = "|\\| %-64s |\\|\n";

while ( <> ) {
    chomp;
    if ( /^0.+~$/ ) {
        print "$_\n$head";
        }
    elsif ( /^Syntax:/ ) {
        printf $format . $format . $format, ' ', $_, ' ';
        }
    elsif ( /^~$/ ) {
        printf $format, ' ';
        print "$tail$_\n\n";
        }
    elsif ( /\S/ ) {
        printf $format, $_;
        }
    }




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to