The following bit of scrolling banner code might help. It uses the "\b" character to erase characters from the terminal.

For anything more advanced I would look for a curses module on CPAN.

#! /usr/bin/perl -w # # file: banner-1.pl # purpose: try to write a scrolling banner # details: this script shows how to implement a scrolling banner # that will run in a xterm window. # # author: chad c d clark # created: 2006-05-21 # # based on the following code by Chris Angell: # perl -e'$|++; 1 while select("","","",.04), # print "\b", qw(/ - \ |)[$i++%4]' # # $Id$ use strict; use POSIX; # ceil() # my $MESG = "This is my test message. "; # my $SIZE = 70; # #my $SIZE = 10; # my $MESG = " " . `/usr/bin/w | /usr/bin/sed 2d`; chomp $MESG; # my $SIZE = 70; my $MESG = qq{ The reason I'm so excited is it looks like if you plot price against profit, you get a nice curve with a big hump in the middle! And we all + know what humps mean! Humps mean local maxima! Or camels. But here they mea +n local maxima! - Joel Spolsky }; my $SIZE = 70; $|++; # do not buffer output I/O # remove "non-printable" characters (for example newlines) if ($MESG =~ s/[^[:print:]]/ /g) { print STDERR "$0: Warning removing non-printable characters from m +essage.\n"; } my $offset = 0; # start at beginning of the message my $length = length $MESG; # get the length of the message # to simulate a circular buffer the idea is to append the message stri +ng # to itself until we have enough extra to cover the display window. my $mult = ceil( ($length + $SIZE) / $length ); $MESG = $MESG x $mult; print "Text: "; # prime the loop for the space where the message will be printed print " " x $SIZE; while (1) { # get a chunk of the message my $chunk = substr $MESG, $offset, $SIZE; # print the chunk over the the last iteration print "\b" x $SIZE, $chunk; select("","","",.15); # sleep for part of a second # advance/wrap the offset pointer if (++$offset >= $length) { $offset = 0 }; } exit(0);

In reply to Re: How do I get my ascii tile code to refresh without looking weird by superfrink
in thread How do I get my ascii tile code to refresh without looking weird by JonPerl

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.