$EXCEPTIONS_BEING_CAUGHT$^SCurrent state of the interpreter. $^S State --------- ------------------------------------- undef Parsing module,eval,or main program true (1) Executing an eval false (0) OtherwiseThe first state may happen in $SIG{__DIE__} and $SIG{__WARN__} handlers.The English name $EXCEPTIONS_BEING_CAUGHT is slightly misleading,because theundef value does not indicate whether exceptions are being caught,since compilation of the main program does not catch exceptions.This variable was added in Perl 5.004.
至于为什么:
C:\Users\user>perl -MBenchmark -E "timethese(20000000,{'caller' => sub {caller()},'$^S' => sub {$^S}})"Benchmark: timing 20000000 iterations of $^S,caller... $^S: 0 wallclock secs ( 0.11 usr + 0.00 sys = 0.11 cpu) @ 183486238.53/s (n=20000000) (warning: too few iterations for a reliable count) caller: 1 wallclock secs ( 0.87 usr + 0.00 sys = 0.87 cpu) @ 22909507.45/s (n=20000000)
这是在我们甚至通过调用堆栈上的多次迭代以及针对堆栈级别运行字符串函数来调低调用者代码之前,假设我们将为所有边缘情况编写无错误代码等.
编写代码以使用调用程序来确定这是核心功能的完整重新实现.这就像问“我如何使用标量实现链表?”答案应该是“使用数组”,而不是“这是怎么回事!”
总结以上是内存溢出为你收集整理的perl – 如何使用调用者确定是否在eval中调用子例程?全部内容,希望文章能够帮你解决perl – 如何使用调用者确定是否在eval中调用子例程?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)