程序:testblocks.pl
#!/usr/bin/perl
use strict;
use warnings;
print "Hi";
BEGIN {
warn "BEGIN";
}
END {
warn "END";
}
INIT {
warn "INIT";
}
CHECK {
warn "CHECK";
}
UNITCHECK {
warn "UNITCHECK";
}
print "Hello";
输出:
BEGIN at testblocks.pl line 8.
CHECK at testblocks.pl line 17.
INIT at testblocks.pl line 14.
UNITCHECK at testblocks.pl line 20.
END at testblocks.pl line 11.
HiHello
现在,如果我\n
在下面的打印语句中使用
print "Hi\n";
...
print "Hello\n";
输出是:
BEGIN at testblocks.pl line 8.
CHECK at testblocks.pl line 17.
INIT at testblocks.pl line 14.
Hi
UNITCHECK at testblocks.pl line 20.
Hello
END at testblocks.pl line 11.
我无法理解这里的问题。任何意见或建议表示赞赏。