首页 文章

使用visual studio代码调试perl

提问于
浏览
5

我今天刚刚开始使用 Perl 并安装 ActivePerl 5.24.1 ,一切顺利 . 我能够使用简单的 print 命令创建我的测试程序 testPerl.pl 并通过 console 运行它 .

现在我想使用 Visual Studio Code 运行我的 Perl Script ,然后用 Visual Studio Code 打开项目文件夹[testPerl.pl location]并尝试调试代码 . 我已经在编辑器中安装了 Perl-Debug 扩展名,当我点击 F5 时,Visual Studio要求我 Select Environment 并且我选择了 Perl Debug 选项,它实际上为我创建了 launch.json 文件,内容如下 .

{
    "version": "0.0.2",
    "configurations": [
        {
            "type": "perl",
            "request": "launch",
            "exec": "perl",
            "name": "Perl-Debug",
            "root": "${workspaceRoot}/",
            "program": "${workspaceRoot}/${command.AskForProgramName}",
            "inc": [],
            "stopOnEntry": true
        }
    ]
}

我保留了默认值,当我再次点击 F5 时,它向我询问了一个默认值为 test.pl 的命令 . 因为 ${command.AskForProgramName} ,我认为 . 我在命令中输入了我的文件名 testPerl.pl ,但后来没有任何反应 . 它在控制台中没有任何 print 开始和结束 .

有人能告诉我如何实际配置这个 launch.json 还是有其他方法我需要这样做吗?

2 回答

  • 0

    我尝试使用较新版本的插件:Perl Debug版本0.2.0 .

    这开箱即用 . 建议的配置如下:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "type": "perl",
                "request": "launch",
                "name": "Perl-Debug local",
                "program": "${workspaceFolder}/${relativeFile}",
                "exec": "perl",
                "execArgs": [],
                "root": "${workspaceRoot}/",
                "inc": [],
                "args": [],
                "env": {},
                "stopOnEntry": true
            },
            {
                "type": "perl",
                "request": "launch",
                "name": "Perl-Debug remote",
                "program": "${workspaceFolder}/${relativeFile}",
                "root": "${workspaceRoot}/",
                "stopOnEntry": true,
                "port": 5000
            }
        ]
    }
    

    请注意我在Mac上尝试使用Visual Studio Code版本1.24.0 .

  • 1

    我在Mac上运行Visual Studio Code并进行了更改

    "program": "${workspaceRoot}/${command.AskForProgramName}"
    

    "program": "${file}"
    

    获取当前文件进行调试 .

相关问题