#!/usr/bin/perl use warnings; use strict; use Tk; require Tk::ROText; my %answers; while (<DATA>) { chomp ( my ( $key, $val ) = split /,\s+/ ); push @{$answers{$key}}, $val; } #print "$_ ", join( ", ", @{$answers{$_}} ), "\n" foreach sort keys %a +nswers; my $mw = new MainWindow; my $txt = $mw->Scrolled('ROText', -scrollbars=> 'ose')->pack; my $ent = $mw->Entry(-bg=>'white')->pack(qw/-fill x -pady 5/); $mw ->bind('<Any-Enter>' => sub { $ent->Tk::focus }); $ent->bind('<Return>' => [\&answer]); MainLoop; sub answer { my ($ent) = @_; my $text = $ent->get; $ent->delete(qw/0 end/); print $text, "\n"; if( ! exists $answers{$text} ){ $txt->insert('end',"$text No Luck\n"); }else{ $txt->insert('end',"$text @{$answers{$text}}\n"); } } __DATA__ What, on second Who, on third When, pitching Where, on first Why, catching How, second Whose, thats what I said
In reply to Re: peter answer game problem
by zentara
in thread peter answer game problem
by anonymoushydrogen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |