I rewrote your program before noting the "Bits I'm after" at the bottom -- I thought you wanted style suggestions. HTH, anyway.
#! /usr/bin/env perl
use diagnostics;
use strict;
use Tk;
use Time::HiRes;
my $BG_COLOUR = $ENV{MY_BG_COLOUR} || "black";
my $FONT = $ENV{MY_FONT} || "-*-Matrix Code NFI-*-*-*--*-200-*";
# http://www.1001fonts.com/font_details.html?font_id=2555
my $GIF = $ENV{MY_GIF} || "C:\\Perl\\tk\\prog2\\matx.gif";
my %MATRIX = (hip => ",\n",
space => "\n"x14,
onegap => " \n");
$MATRIX{$_} = "$_\n" for qw/a b c d e f g H i j k l n o r s w y/;
my $ITERATIONS = $ENV{MY_ITERATIONS} || 0;
my $main = MainWindow->new(-title => "Matrix...", -bg => $BG_COLOUR);
$main->minsize(qw(422 200));
$main->maxsize(qw(422 200));
$main->idletasks; # necessary !
$main->iconimage($main->Photo(-file => $GIF));
$main->Frame(-bg => $BG_COLOUR)->pack(-side => 'left',
-fill => 'y');
# --------------------------------------------------------------------
+--
package MatrixBoxes;
sub new {
my @m;
for (1..3) {
push @m, $main->Text(-width => "2",
-background => $BG_COLOUR,
-font => $FONT,
-foreground => "lightgreen",
-wrap => "none",
-relief => 'flat')->pack(-side => 'right',
-fill => 'y');
}
bless \@m;
}
sub Contents { my $m = shift; for (@$m) { $_->Contents(@{+shift}) } }
sub configure { my $m = shift; for (@$m) { $_->configure(@_) } }
sub yscroll { my $m = shift; for (@$m) { $_->yviewScroll(shift, 'units
+') } }
# --------------------------------------------------------------------
+--
package main;
my $m = MatrixBoxes->new;
sub five{
my @let1 = @MATRIX{qw/d l r o w onegap o l l e H space/};
my @let2 = @MATRIX{qw/n i a g a onegap o l l e H space/};
my @let3 = @MATRIX{qw/onegap onegap onegap y o b onegap d a b onegap
+ onegap onegap onegap onegap space/};
$m->Contents(\@let1, \@let2, \@let3);
$m->configure(-state => 'disabled');
$m->yscroll(37, 67, 27);
for (1..27) {
$m->yscroll(-1, -2, -1);
$main->update;
Time::HiRes::sleep(0.1);
}
}
five for 0..$ITERATIONS;
MainLoop;