#!/usr/bin/perl -w use strict; use Tk; my @data = ; chomp @data; my $main = MainWindow->new(-title => "God's Billboards"); my $form = $main->Frame()->pack(-side => 'top', -fill => 'both', -padx => 5, -pady => 5); my $message = $form->Frame()->pack(-side => 'right', -fill => 'both', -padx => 5, -pady => 5); my $message_val = $message->Text(-height => 3, -width => 40)->pack(-side => 'right'); my $buttons = $main->Frame()->pack(-side => 'bottom'); my $sendbutton = $buttons->Button(-text => 'Next', -command => \&Display)->pack(-side => 'top'); CenterWindow($main); Display(); # set text before entering MainLoop MainLoop(); sub CenterWindow { # Don't remember where I got this subroutine # Args: (0) window to center # (1) [optional] desired width # (2) [optional] desired height my ($window, $width, $height) = @_; $window->idletasks; $width = $window->reqwidth unless $width; $height = $window->reqheight unless $height; my $x = int(($window->screenwidth / 2) - ($width / 2)); my $y = int(($window->screenheight / 2) - ($height / 2)); $window->geometry($width . "x" . $height . "+" . $x . "+" . $y); } sub Next { my $quip = shift(@data); push(@data, $quip); $quip =~ s/\\n/\n/g; $quip .= "\n - God"; return $quip; } sub Display { $message_val->delete('0.0', 'end'); $message_val->insert('0.0', Next()); } __DATA__ Tell the kids I love them. Let's meet at my house Sunday before the\ngame. Keep using my name in vain,\nI'll make rush hour longer. What part of "Thou Shalt Not..."\ndidn't you understand? We need to talk. C'mon over and bring the kids. Have you read my #1 best seller?\nThere will be a test. That "Love Thy Neighbor" thing... \nI meant it. I love you and you and you and you\nand... Will the road you're on get you to my\nplace? Big bang theory, you've got to be\nkidding. My way is the highway. Need directions? You think it's hot here? Loved the wedding, invite me to the\nmarriage. Do you have any idea where you're going? Follow me. Don't make me come down there.