Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
> or print variables named via regex.

The following commands dump variables by regex

DB<162> h X X [vars] Same as "V currentpackage [vars]". DB<163> h V V [pkg [vars]] List some (default all) variables in package (defaul +t current). Use ~pattern and !pattern for positive and negative regexps. DB<164> h y y [n [Vars]] List lexicals in higher scope <n>. Vars same as V.

With "{" you can tell the debugger to automatically execute these (and other debugger) commands with each prompt, like when single stepping or when running into a breakpoint.

DB<1> h { { db_command Define debugger command to run before each prompt. { ? List debugger commands to run before each prompt. {{ db_command Add to the list of debugger commands to run before ea +ch prompt. { * Delete the list of debugger commands to run before eac +h prompt.

The following example

  • sets a conditional breakpoint at line 11
  • dumps all variables named y before each prompt
c = continue runs into the breakpoint s = single step shows the dumping

DB<239> b 11 $a==3 DB<240> L d:/Users/RolfLangsdorf/AppData/Roaming/pm/tst_debuger.pl: 11: $a++; break if ($a==3) DB<240> { X y DB<241> { pre-debugger commands: { -- X y DB<241> c 0123auto(-1) DB<241> X y $y = 3 DB<242> s auto(-1) DB<242> X y $y = 3 DB<243> s auto(-1) DB<243> X y $y = 4 DB<244> c 45678910auto(-1) DB<244> X y DB<245>

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!


In reply to Re: How can I print variable contents from the debugger non-interactively? ( { = auto cmd ; X V y = dump by regex) by LanX
in thread How can I print variable contents from the debugger non-interactively? by davehorner

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-03-28 20:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found