简体   繁体   English

我怎样才能在 Perl 调试器中死掉?

[英]How can I throw die in Perl debugger?

I want to debug my Perl code with die.我想用 die 调试我的 Perl 代码。

I wrote this code.我写了这段代码。

eval {
  print("foo");
  print("bar");
  print("fizz");
  print("buzz");
}

if ($@) {
  print("error");
}

*Of course this code is an abstracted sample. *当然这个代码是一个抽象的示例。

I want to run "if" route in the debugger without any code changes.我想在调试器中运行“if”路由而不更改任何代码。

I want to run "if" route of this code in the debugger.我想在调试器中运行此代码的“if”路由。

The debugger doesn't change what the program does.调试器不会改变程序的行为。 You can change the value of variables, but that's it.您可以更改变量的值,仅此而已。

Fortunately, the code in question is executed based on the value of $@ .幸运的是,有问题的代码是根据$@的值执行的。 So you would set the value of $@ to something true.因此,您可以将$@的值设置为 true。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM