我喜歡跳過while(1)
之後。怎麼做? 檢查特殊變量和last
不正確,因爲while表達式包含阻止調用的,所以如果檢查表達式就太遲了。如何在while(1)之後通過SIGHUP在Perl中跳轉?
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(say);
use sigtrap 'handler', \&hup_handler, 'HUP';
my $counter = 0;
sub hup_handler { say 'HUP!!!'; $counter = 0; return; }
say 'It starts here';
while (1) {
sleep(1); # Blocking call is in reality within while expression.
say ++$counter;
}
say 'It ends here';
你是什麼意思?你的意思是打破循環?嘗試休息; –
@Perroloco這是一個Perl問題。 Perl中沒有'break'命令(在循環的上下文中)。 – simbabque
'last'以及任何**太遲**因爲'while'表達式中的**阻塞**調用。 – burnersk