Is there a way to turn on tracing in perl (equivalent to bash -x)?

前端 未结 4 1448
滥情空心
滥情空心 2020-12-30 18:54

I have a system script in perl. I need some equivalent of bash -x to determine what is going wrong with the script. Is there something equivalent?

EDIT: What bash -x

4条回答
  •  失恋的感觉
    2020-12-30 19:52

    The Devel::DumpTrace module has been available since 2011.

    Sample usage:

    $ cat demo.pl
    # demo.pl
    # a demonstration of Devel::DumpTrace
    $a = 1;
    $b = 3;
    $c = 2 * $a + 7 * $b;
    @d = ($a, $b, $c + $b);
    
    $ perl -d:DumpTrace demo.pl
    >>>>> demo.pl:3:        $a:1 = 1;
    >>>>> demo.pl:4:        $b:3 = 3;
    >>>>> demo.pl:5:        $c:23 = 2 * $a:1 + 7 * $b:3;
    >>>>> demo.pl:6:        @d:(1,3,26) = ($a:1, $b:3, $c:23 + $b:3);
    

提交回复
热议问题