我正试图在档案开启有错误时,让我的指挥迅速关闭。 我已经尝试了死亡的指挥,但是,在发出信号后,立即关闭指挥系统。 我想能够打印错误信息,等待几秒,然后关闭或退出。 现在,我可以坐下来,等待迅速结束。
open (LOG1, $file1) || (print "
# Error in opening $file1, make sure it exists! #
", sleep(3), exit);
我正试图在档案开启有错误时,让我的指挥迅速关闭。 我已经尝试了死亡的指挥,但是,在发出信号后,立即关闭指挥系统。 我想能够打印错误信息,等待几秒,然后关闭或退出。 现在,我可以坐下来,等待迅速结束。
open (LOG1, $file1) || (print "
# Error in opening $file1, make sure it exists! #
", sleep(3), exit);
页: 1 而是使用半殖民地。
我认为,你正在使用Windows系统。 如果是的话,你可以尝试在你的文字中增加以下代码,显示: • 出版任何关键材料,以便在文字出走之前继续......。
END { system pause }
我怀疑sleep
产出缓冲没有变化,因此可以解释为什么你不看到任何印刷材料;你可以尝试:
open (LOG1, $file1) || ((print "
# Error in opening $file1, make sure it exists! #
"), $|++, sleep(3), exit);
无论如何,在我看来,最好确定一个<条码>dieAfterDelay的功能,如:
sub dieAfterDelay {
my $msg = shift;
my $delay = shift;
my $errNo = shift;
print $msg . "
", $|++;
sleep($delay);
exit($errNo);
}
您可以这样做:
open (LOG1, $file1) || dieAfterDelay("
# Error in opening $file1, make sure it exists! #
", 3, -1);
I am building a Web interface to monitor an embedded system. I have built a Perl script which runs remote commands and gathers output from that system. Now what I need is a Web interface which makes ...
How do I tell what type of value is in a Perl variable? $x might be a scalar, a ref to an array or a ref to a hash (or maybe other things).
When I try a "chdir" with a filehandle as argument, "chdir" returns 0 and a pwd returns still the same directory. Should that be so? I tried this, because in the documentation to chdir I found: "...
I ve read the doc for GetOptions but I can t seem to find what I need... (maybe I am blind) What I want to do is to parse command line like this myperlscript.pl -mode [sth] [inputfile] I can use ...
I m a little confused about what is going on in Perl constructors. I found these two examples perldoc perlbot. package Foo; #In Perl, the constructor is just a subroutine called new. sub new { #I ...
I would like to submit a form to a CGI script localy (w3c-markup-validator), but it is too slow using curl and apache, I want to use this CGI script more than 5,000 times in an another script. and ...
So I m running perl 5.10 on a core 2 duo macbook pro compiled with threading support: usethreads=define, useithreads=define. I ve got a simple script to read 4 gzipped files containing aroud 750000 ...
A Google search yields a number of results - but which ones are the best? The Perl site appears to contain two - perlboot and perltoot. I m reading these now, but what else is out there? Note: I ve ...