1
我想送已取消通知:像警告:: warnif('deprecated'...)用鯉魚?
warnings::warnif('deprecated', 'function foo is deprecated');
,但我更願意把它鯉魚起來所以它報告給調用者,而不是在實際的警告是。我可以用以某種方式做到這一點嗎?
我想送已取消通知:像警告:: warnif('deprecated'...)用鯉魚?
warnings::warnif('deprecated', 'function foo is deprecated');
,但我更願意把它鯉魚起來所以它報告給調用者,而不是在實際的警告是。我可以用以某種方式做到這一點嗎?
package Foo {
sub bar {
warnings::warnif(deprecated => 'Foo:bar is deprecated');
}
}
use warnings;
# no warnings 'deprecated'; # <-- uncomment this to disable the warning
Foo::bar(); # <-- this is line 9
這應該這樣說:
Foo::bar is deprecated at test.pl line 9.
其實,看着warnings.pm source,似乎在內部使用Carp.pm。誠然,對於警告編譯器的文檔可能是這個清晰,但perllexwarn不讓它非常清楚,這是它的意思是如何被使用。
是的,我試了一下..在MOP顯然即使是現在,我已經設置'擺脫我所有的行號... @ CARP_NOT'適當,所以我不知道它是做正確的事(或原「@ CARP_NOT」會被服從)。現在,我想我需要弄清楚什麼我失蹤,因爲我把'__PACKAGE__'在'@ CARP_NOT'但它仍然似乎是從包裝,而不是測試文件吹毛求疵。 – xenoterracide
[後續問題](http://stackoverflow.com/q/18004716/206466) – xenoterracide