我是Perl和Curses的新手,但是我很难让我的代码运行循环,从这里开始我的代码:
#!/usr/bin/env perl
use strict;
use Curses::UI;
sub myProg {
my $cui = new Curses::UI( -color_support => 1 );
my $win = $cui->add(
"win", "Window",
-border => 1,
);
my $label = $win->add(
'label', 'Label',
-width => -1,
-paddingspaces => 1,
-text => 'Time:',
);
$cui->set_binding( sub { exit(0); } , "\cC");
# I want this to loop every second
$label->text("Random: " . int(rand(10)));
sleep(1);
$cui->mainloop();
}
myProg();
Run Code Online (Sandbox Code Playgroud)
如您所见,我希望此部分以递归方式运行:
# I want this to loop every second
$label->text("Random: " . …Run Code Online (Sandbox Code Playgroud)