Debug a Perl Program

Source: Internet
Author: User

On the console, enter perldoc perldebug to learn how to debug the Perl program.

The important commands are as follows:

P expr same as "Print {$ DB: Out} expr" in the current package. In
Particle, because this is just Perl's own "print"
Function, this means that nested data structures and objects
Are not dumped, unlike with the "X" command.

X [maxdepth] expr
Evaluates its expression in list context and dumps out
Result in a pretty-printed fashion.

T produce a stack backtrace. See below for details on its

S [expr] single step. executes until the beginning of another
Statement, descending into subroutine CILS. If
Expression is supplied that extends des function CILS, it too
Will be single-stepped.

N [expr] Next. executes over subroutine CILS, until the beginning
The next statement. If an expression is supplied that
Except des function CILS, those functions will be executed
With stops before each statement.

R continue until the return from the current subroutine. Dump
The return value if the "printret" option is set (default ).

<CR> repeat last "N" or "S" command.

L [ABW] list (default all) Actions, breakpoints and watch

L list next window of lines.

L line list a single line.

L subname list first window of lines from subroutine. * subname * may be
A variable that contains a code reference.

B sets breakpoint on current line

B [Line] [condition]
Set a breakpoint before the given line. If a condition is
Specified, it's evaluated each time the statement is
Reached: a breakpoint is taken only if the condition is
True. breakpoints may only be set on lines that begin
Executable statement. conditions don't use "if ":

B 237 $ x> 30
B 237 + $ count237 <11
B 33/pattern/I

B subname [condition]
Set a breakpoint before the first line of the named
Subroutine. * subname * may be a variable containing a code
Reference (in this case * condition * is not supported ).

C [Line | sub]
Continue, optionally inserting a one-time-only breakpoint
The specified line or subroutine.

Q or ^ d quit. ("quit" doesn't work for this, unless you 've made
Alias) This is the only supported way to exit the debugger,
Though typing "exit" Twice might work.

Set the "inhibit_exit" option to 0 if you want to be able
Step off the end the script. You may also need to set
$ Finished to 0 if you want to step through global

R restart the debugger by "Exec ()" ing a new session. We try
Maintain your history guest SS this, but internal settings and
Command-line options may be lost.

The following setting are currently preserved: history,
Breakpoints, actions, debugger options, and the perl
Command-line options-W,-I, and-e.

W expr Add a Global Watch-expression. Whenever a watched global
Changes the debugger will stop and display the old and new

W expr Delete watch-expression

W * Delete all watch-expressions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.