Monday, January 3, 2011

Perl debugger commands



🚀 Invoking & Quitting

  • perl -d script.pl — Start the Perl debugger for a script.

  • q — Quit the debugger.

Note: All commands below are executed from within the active debugger prompt.

📜 Listing & Viewing Source Code

  • l — List the next window of lines.

  • l line_number — List code around a specific line number.

  • l subroutine_name — List the first window of lines from a specified subroutine.

  • v — View lines of code around the current execution line.

🛑 Managing Breakpoints

  • b — Set a breakpoint at the current line.

  • b line_number [condition] — Set a breakpoint before a specified line (optional condition, e.g., b 12 $color == "red").

  • b subroutine_name [condition] — Set a breakpoint before a specified subroutine (optional condition; note that if subroutine_name is a code reference variable, conditions cannot be used).

  • L b — List all defined breakpoints.

  • B line_number — Delete a breakpoint from a specified line.

  • B * — Delete all breakpoints.

⚡ Stepping Through the Code

  • s — Execute a single statement, descending into subroutine calls (Step Into).

  • n — Execute a single statement, without descending into subroutine calls (Step Over).

  • r — Execute all statements until the return of the current subroutine.

  • c — Continue execution:

    • c — Run with no breakpoint.

    • c line_number — Run and insert a one-time-only temporary breakpoint at a line.

    • c subroutine_name — Run and insert a one-time-only temporary breakpoint at a subroutine.