What are some good Perl debugging methods?

前端 未结 18 1116
南笙
南笙 2020-12-12 21:12

Are there other ways for debugging Perl programs apart from Data::Dumper and perl -d?

18条回答
  •  情歌与酒
    2020-12-12 21:36

    Personally, I'm a big fan of Smart::Comments. It makes tracing dead simple, and there isn't any need to strip it out again, either.

    use Smart::Comments -ENV;
    ...
    sub myroutine {
        my ($self, @args) = @_ ;
        ### args: @args
        ...
    }
    

    If Smart_Comments has been set in the environment, the lines commencing with ### are converted to debug output, with Dumper() used automagically. If the environment variable isn't set, the debug stuff is completely inert.

    It has heaps of features and will produce progress bars, warnings, abort conditions as well as plain old debug output.

    Appropriate tests are all good, and I'm not dismissing a good test-driven development (TDD) development methodology, but when trying to get to the bottom of an existing bug, Smart::Comments is the go.

提交回复
热议问题