Debian Codegraph @

Contrib/book-examples/lusol-f16.3

raw
1 From [email protected] Fri May 10 17:56:04 1996
2 Return-Path: <[email protected]>
3 From: [email protected] (Stephen O. Lidie)
4 Message-Id: <[email protected]>
5 Subject: book_examples: Figure 16.3
6 To: [email protected]
7 Date: Fri, 10 May 1996 12:55:17 -0400 (EDT)
8 X-Mailer: ELM [version 2.4 PL25]
9 Content-Type: text/plain; charset=US-ASCII
10 Content-Transfer-Encoding: 7bit
11 Sender: [email protected]
12 Precedence: bulk
13 P-From: "Stephen O. Lidie" <[email protected]>
14
15 Hey, I never saw those before (; Here are two ways to handle F16.3, the
16 first non-strict/with symbolic references, the second strict/hard refs.
17
18 -------------------------------- 1 -------------------------------------------
19 #!/usr/local/bin/perl -w
20
21 #
22 # Figure 16.3, p162
23 #
24
25
26 # how to do this ?
27 # Like this: (;
28
29 use Tk;
30 #use strict;
31 use subs qw(watch);
32
33 my $mw = MainWindow->new;
34 $country = "Japan"; # can't be a my() variable - must appear in symbol table
35 watch 'country';
36 $mw->after(5000, sub {$country = "Great Britain"});
37
38 sub watch {
39 my ($name) = @_;
40 $mw->Label(-text => "Value of \"$name\": ")->pack (-side => 'left');
41 $mw->Label(-textvariable => \$$name)->pack(-side => 'left');
42 }
43
44 MainLoop;
45 -------------------------------- 2 -------------------------------------------
46 #!/usr/local/bin/perl -w
47
48 #
49 # Figure 16.3, p162
50 #
51
52
53 # how to do this ?
54 # Like this: (;
55
56 use Tk;
57 use strict;
58 use subs qw(watch);
59
60 my $mw = MainWindow->new;
61 my $country = "Japan";
62 watch 'country', \$country;
63 $mw->after(5000, sub {$country = "Great Britain"});
64
65 sub watch {
66 my ($name, $var_ref) = @_;
67 $mw->Label(-text => "Value of \"$name\": ")->pack (-side => 'left');
68 $mw->Label(-textvariable => \$var_ref)->pack(-side => 'left');
69 }
70
71 MainLoop;
72
73 ==========================================================================
74 This message was posted through the Stanford campus mailing list
75 server. If you wish to unsubscribe from this mailing list, send the
76 message body of "unsubscribe ptk" to [email protected]