Wieso bitte wird $heap->{counter} erhöht ? Ich kann niergenswo ne schleife finden oder eine Funktion die ui_count() immerwieder aufruft... ?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
use warnings;
use strict;
# Tk support is enabled if the Tk module is used before POE itself.
use Tk;
use POE;
# Create the session that will drive the user interface.
POE::Session->create(
inline_states => {
_start => \&ui_start,
ev_count => \&ui_count,
ev_clear => \&ui_clear,
}
);
$poe_kernel->run();
exit 0;
sub ui_start {
my ( $kernel, $session, $heap ) = @_[ KERNEL, SESSION, HEAP ];
$poe_main_window->Label( -text => "Counter" )->pack;
$heap->{counter_widget} =
$poe_main_window->Label( -textvariable => \$heap->{counter} )->pack;
$poe_main_window->Button(
-text => "Clear",
-command => $session->postback("ev_clear")
)->pack;
$kernel->yield("ev_count");
}
sub ui_count {
$_[HEAP]->{counter}++;
$_[KERNEL]->yield("ev_count");
}
sub ui_clear {
$_[HEAP]->{counter} = 0;
}