banner_rotate.pl for linux /usr/games/banner 
Author Message
 banner_rotate.pl for linux /usr/games/banner

This is a perl script (tchrist: can't a monologue be scripted ?:)
for taking the output of the linux banner program (or any other one
which prints banners horizontally down the page) and rotates the letters
to read l to r.  Makes w---i---d----e output!!

SPAMMERS look elsewhere! This is NOT a doodad to cycle through
adverti{*filter*}ts on a web page. Hey man, I gotta sleep at night.

Use it like this:

  $ banner "Just another perl hacker" | rotate_banner

Make your xterm font "unreadable" and the window as wide as you can
get it.  I don't know *why* you might want to do this.

NOTE: it works by finding a blank line between letters. If you
shrink the font with the "banner -w nn" option, it probably
won't work as banner omits this blank line.

!  #!/usr/bin/perl
!  


!  
!  for ($i=0; $i < $#a; $i++) {  # what is the longest line?
!     $tall=length ($a[$i]) if ($tall < length ($a[$i]));
!  }
!  
!  for ($i=0; $i < $#a; $i++) {
!     if ($a[$i] =~ /^\s*$/) {   #blank line?
!        if ($got) {
!            &pack_rotated;
!            $got=0;
!        }
!        for $charnum (0 .. $tall) {   # add a blank line
!           $b[$charnum] .= " ";
!        }
!     } elsif ($got) {  # not blank line.. inside a letter?
!        $end ++;
!     } else {  # not blank line.. begin a letter
!        $start=$end=$i;
!        $got=1;
!     }
!  }
!  
!  # at eof...
!  &pack_rotated if $got;
!  
!  # print it!

!    print "$l\n";
!  }
!  
!  sub pack_rotated {
!     foreach $linenum ($start .. $end) {
!        $tmp=$a[$linenum] . " " x ($tall - length ($a[$linenum])); # pad w/blanks
!        for $charnum (0 .. length ($tmp)) {  # length($tmp)=$tall
!           $b[$charnum] .= substr($tmp,$tall-$charnum,1);
!        }
!     }
!  }

--

Freaks only: http://www.*-*-*.com/

I need to collect some of your SPAM for analysis. Can you go into
the lavatory and ADVERTISE into this cup?



Sun, 16 Dec 2001 03:00:00 GMT  
 banner_rotate.pl for linux /usr/games/banner
     [courtesy cc of this posting mailed to cited author]


:This is a perl script for taking
:the output of the linux banner program

POBs and other unfortunates can use the PPT project's banner program
to see what you're doing. (http://language.perl.com/ppt/)

#!/usr/bin/perl -w
# * banner - prints large signs
# * banner [-w#] [-d] [-t] message ...

# This is a translation from C of the BSD banner.c source, which bears the
# following copyright notice:
#
# /*
#  * Copyright (c) 1980, 1993, 1994
#  *    The Regents of the University of California.  All rights reserved.
#  *
#  * Redistribution and use in source and binary forms, with or without
#  * modification, are permitted provided that the following conditions
#  * are met:
#  * 1. Redistributions of source code must retain the above copyright
#  *    notice, this list of conditions and the following disclaimer.
#  * 2. Redistributions in binary form must reproduce the above copyright
#  *    notice, this list of conditions and the following disclaimer in the
#  *    documentation and/or other materials provided with the distribution.
#  * 3. All advertising materials mentioning features or use of this software
#  *    must display the following acknowledgement:
#  *    This product includes software developed by the University of
#  *    California, Berkeley and its contributors.
#  * 4. Neither the name of the University nor the names of its contributors
#  *    may be used to endorse or promote products derived from this software
#  *    without specific prior written permission.
#  *
#  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
#  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
#  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
#  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
#  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
#  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
#  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
#  * SUCH DAMAGE.
#  */

use strict;
require 5.004;

use constant MAXMSG => 1024;
use constant DWIDTH => 132;

END {
    close STDOUT || die "$0: can't close stdout: $!\n";
    $? = 1 if $? == 255;  # from die

Quote:
}

sub usage { die "usage: $0 [-w width]\n" }

# Character data


my %ascii_to_table;

# options
my $width = DWIDTH;

  local $_ = shift;
  /^[h?]$/ && usage();
  if (s/^w//) {
    if    (length) { $width = $_ }

    else           { die "$0: option requires an integer argument -- w\n" }
    if ($width =~ /\D/ || $width == 0) {
      # the original source silently defaults to 80 cols.
      # I think that's rude.
      warn "Don't understand -w argument `$width'.  Using 80 columns.\n";
      $width = 80;
    }
    next;
  }
  warn "$0: illegal option -- $_\n";
  usage();

Quote:
}

# scale characters to width

for (my $i = 0; $i < $width; $i++) {
  $printmask[$i * 132 / $width] = 1;

Quote:
}

# get message
my $message;

else {
  print STDERR "Message: ";
  chomp($message = <STDIN>);

Quote:
}

# check message
my $ok = 1;
while ($message =~ /(.)/g) {
  unless ($ascii_to_table{$1}) {
    $ok = 0;
    warn "$0: The character `$1' is not in my character set.\n";
  }
Quote:
}

exit 1 unless $ok;

# print banner
while ($message =~ /(.)/g) {

  my $pc = $ascii_to_table{$1};
  my $term = my $max = my $linen = 0;
  while (!$term) {
    if ($pc < 0 || $pc > $#data_table) { die "$0: bad pc $pc\n" }
    my $x = $data_table[$pc] & 0377;
    if ($x >= 128) {
      ++$term if $x > 192;
      $x &= 63;
      while ($x--) {
        if ($printmask[$linen++]) {
          for (my $i = 0; $i <= $max; $i++) {
            print $line[$i] if $printmask[$i];
          }
          print "\n";
        }
      }

      $pc++;
    }
    else {  # $x < 128
      my $y = $data_table[$pc+1];
      $max = $x + $y;
      while ($x < $max) { $line[$x++] = '#' }
      $pc += 2;
    }
  }

Quote:
}

exit 0;

BEGIN {

    (

        0,      0,      0,      0,      0,      0,      0,      0,  # ^H
        0,      0,      0,      0,      0,      0,      0,      0,  # ^P
        0,      0,      0,      0,      0,      0,      0,      0,  # ^X
        1,      3,     50,     81,    104,    281,    483,    590,  #    
      621,    685,    749,    851,    862,    893,    898,    921,  #  (
     1019,   1150,   1200,   1419,   1599,   1744,   1934,   2111,  #  0
     2235,   2445,   2622,   2659,      0,   2708,      0,   2715,  #  8

     3965,   4000,   4015,   4115,   4281,   4314,   4432,   4548,  #  H
     4709,   4790,   4999,   5188,   5397,   5448,   5576,   5710,  #  P
     5892,   6106,   6257,      0,      0,      0,      0,      0,  #  X
       50,   6503,   6642,   6733,   6837,   6930,   7073,   7157,  #  `
     7380,   7452,   7499,   7584,   7689,   7702,   7797,   7869,  #  h
     7978,   8069,   8160,   8222,   8381,   8442,   8508,   8605,  #  p
     8732,   8888,   9016,      0,      0,      0,      0,      0   #  x
    );

  # Table of stuff to print. Format:
  # 128+n -> print current line n times.
  # 64+n  -> this is last byte of char.
  # else, put m chars at position n (where m is the next elt in array)
  # and goto second next element in array.

    (
     #0     1     2     3     4     5     6     7     8     9
     129,  227,  130,   34,    6,   90,   19,  129,   32,   10,  #    0
      74,   40,  129,   31,   12,   64,   53,  129,   30,   14,  #   10
      54,   65,  129,   30,   14,   53,   67,  129,   30,   14,  #   20
      54,   65,  129,   31,   12,   64,   53,  129,   32,   10,  #   30
      74,   40,  129,   34,    6,   90,   19,  129,  194,  130,  #   40
      99,    9,  129,   97,   14,  129,   96,   18,  129,   95,  #   50
      22,  129,   95,   16,  117,    2,  129,   95,   14,  129,  #   60
      96,   11,  129,   97,    9,  129,   99,    6,  129,  194,  #   70
     129,   87,    4,  101,    4,  131,   82,   28,  131,   87,  #   80
       4,  101,    4,  133,   82,   28,  131,   87,    4,  101,  #   90
       4,  131,  193,  129,   39,    1,   84,   27,  129,   38,  #  100
       3,   81,   32,  129,   37,    5,   79,   35,  129,   36,  #  110
       5,   77,   38,  129,   35,    5,   76,   40,  129,   34,  #  120
       5,   75,   21,  103,   14,  129,   33,    5,   74,   19,  #  130
     107,   11,  129,   32,    5,   73,   17,  110,    9,  129,  #  140
      32,    4,   73,   16,  112,    7,  129,   31,    4,   72,  #  150
      15,  114,    6,  129,   31,    4,   72,   14,  115,    5,  #  160
     129,   30,    4,   71,   15,  116,    5,  129,   27,   97,  #  170
     131,   30,    4,   69,   14,  117,    4,  129,   30,    4,  #  180
      68,   15,  117,    4,  132,   30,    4,   68,   14,  117,  #  190
       4,  129,   27,   97,  131,   30,    5,   65,   15,  116,  #  200
       5,  129,   31,    4,   65,   14,  116,    4,  129,   31,  #  210
       6,   64,   15,  116,    4,  129,   32,    7,   62,   16,  #  220
     115,    4,  129,   32,    9,   61,   17,  114,    5,  129,  #  230
      33,   11,   58,   19,  113,    5,  129,   34,   14,   55,  #  240
      21,  112,    5,  129,   35,   40,  111,    5,  129,   36,  #  250
      38,  110,    5,  129,   37,   35,  109,    5,  129,   38,  #  260
      32,  110,    3,  129,   40,   27,  111,    1,  129,  193,  #  270
     129,   30,    4,  103,    9,  129,   30,    7,  100,   15,  #  280
     129,   30,   10,   99,   17,  129,   33,   10,   97,    6,  #  290
     112,    6,  129,   36,   10,   96,    5,  114,    5,  129,  #  300
      39,   10,   96,    4,  115,    4,  129,   42,   10,   95,  #  310
       4,  116,    4,  129,   45,   10,   95,    3,  117,    3,  #  320
     129,   48,   10,   95,    3,  117,    3,  129,   51,   10,  #  330
      95,    4,  116,    4,  129,   54,   10,   96,    4,  115,  #  340
       4,  129,   57,   10,   96,    5,  114,    5,  129,   60,  #  350
      10,   97,    6,  112,    6,  129,   63,   10,   99,   17,  #  360
     129,   66,   10,  100,   15,  129,   69,   10,  103,    9,  #  370
     129,   39,    9,   72,   10,  129,   36,   15,   75,   10,  #  380
     129,   35,   17,   78,   10,  129,   33,    6,   48,    6,  #  390
      81,   10,  129,   32,    5,   50,    5,   84,   10,  129,  #  400
      32,    4,   51,    4,   87,   10,  129,   31,    4,   52,  #  410
       4,   90,   10,  129,   31,    3,   53,    3,   93,   10,  #  420
     129,   31,    3,   53,    3,   96,   10,  129,   31,    4,  #  430
      52,    4,   99,   10,  129,   32,    4,   51,    4,  102,  #  440
      10,  129,   32,    5,   50,    5,  105,   10,  129,   33,  #  450
       6,   48,    6,  108,   10,  129,   35,   17,  111,   10,  #  460
     129,   36,   15,  114,    7,  129,   40,    9,  118,    4,  #  470
     129,  193,  129,   48,   18,  129,   43,   28,  129,   41,  #  480
      32,  129,   39,   36,  129,   37,   40,  129,   35,   44,  #  490
     129,   34,   46,  129,   33,   13,   68,   13,  129,   32,  #  500
       9,   73,    9,  129,   32,    7,   75,    7,  129,   31,  #  510
       6,   77,    6,  129,   31,    5,   78,    5,  129,   30,  #  520
       5,   79,    5,  129,   20,   74,  132,   30,    4,   80,  #  530
       4,
...

read more »



Sun, 16 Dec 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. MS Shell Game (Was: MS Word Viewer for Linux)

2. bug in IRIX 5.x perl library /usr/lib/perl/syslog.pl

3. /usr/bin/perl vs /usr/local/bin/perl

4. #!/usr/local/bin/perl -w || /usr/bin/perl -w

5. 5.005 in /usr/bin and 5.6.0 in /usr/local/bin

6. Comm.pl good on Linux, bad on HP-UX

7. Wierd Linux chat2.pl problem with sockname

8. Comm.pl works fine on Linux, not on SunOS

9. Problems running Makefile.PL on Linux

10. Comm.pl and Linux

11. Comm.pl and Linux (2.2 or greater)

 

 
Powered by phpBB® Forum Software