前段时间我遇到了问题,$SIG{WINCH}
因为我加载了两个在模块中使用$SIG{WINCH}
$SIG{WINCH} 时都使用问题的模块。现在我试图重建这个案例,但这次我把一个模块$SIG{WINCH}
放在一个子程序中。
use warnings;
use strict;
package My_Package;
use Exporter 'import';
our @EXPORT = qw(choose);
sub choose {
# ...
my $size_changed;
local $SIG{WINCH} = sub { $size_changed = 1; }; # edit: added "local"
while ( 1 ) {
my $c = getch();
if ( $size_changed ) {
write_screen();
$size_changed = 0;
next;
}
# ...
}
}
现在看起来它正在工作。如果我$SIG{WINCH}
以这种方式进行本地化,我会保存还是在重建时忘记了什么?