3

I want to interactively debug the Perl CGI using Perl debugger on a remote linux machine using VSCode. I tried every possible thing on internet to achieve this but didn't get any success, finally I have come here to get some help.

I want to set a breakpoint in VSCode and send a request from browser and want my code to stop at my breakpoint in VSCode and want to debug my Perl script interactively on remote machine.

I installed Perl debug extension on VSCode, then I installed Perl Language Server on remote machine, then I established the remote ssh connection got success with it, Now I have to setup launch.json but don't know which program I should launch or attach.

I am able to debug any standalone script using launch.json, but I want to send a request from browser to an .pl with some Post values and then I want my script to stop at the breakpoint I have set on VSCode and start debugging it interactively.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
Badal Dave
  • 31
  • 1
  • *"I am able to debug any standalone script using launch.json"* Can you provide more details on how you set this up? Then we can try to reproduce – Håkon Hægland Feb 19 '23 at 19:46
  • 1
    Referring https://stackoverflow.com/questions/41734738/debugging-perl-with-visual-studio-code – Badal Dave Feb 20 '23 at 03:52

1 Answers1

0

Export some variables and call the cgi on commandline, would i say if your not in vscode...

export QUERY_STRING=”a=1&foo=bar″ 
export REQUEST_METHOD=”GET” 

# script call
perl -dT Your_cgi.pl

As a workaround you could set these environment variables with this syntax in your script.

ENV["QUERY_STRING"] = 'a=1&foo=bar';

I found out yet, this question was answered already here How can I troubleshoot my Perl CGI script?

Oliver Gaida
  • 1,722
  • 7
  • 14