Loginskip to content

October 28th, 2006

Examine references to hashes instead of the hashes

Examine references to hashes instead of the hashes themselves in the debugger to get well-formatted output. 7.2.3 Examining Source: l, -, w, . Sometimes you want more of the context of your program than just the current line. The following commands show you parts of your source code: l List successive windows of source code starting from the current line about to be executed. lx+y List y + 1 lines of source starting from line x. lx-y List source lines x through y. -List successive windows of source code before the current line. w List a window of lines around the current line. w line List a window of lines around line. . Reset pointer for window listings to current line. Source lines that are breakable (i.e., can have a breakpoint inserted before them see the following section) have a colon after the line number. 7.2.4 Playing in the Sandbox Since the debugger is a full-fledged Perl environment, you can type in Perl code on the fly to examine its effects under the debugger;[1] some people do this as a way of testing code quickly without having to enter it in a script or type in everything perfectly before hitting end- of-file. (You just saw us do this at the end of section 7.2.2.) [1] So, you might wonder, how would you enter Perl code which happened to look like a debugger command (because you’d defined a subroutine l, perhaps)? In versions of Perl prior to 5.6.0, if you enter leading white space before text, the debugger assumes it must be Perl code and not a debugger command. So be careful not to hit the space bar by accident before typing a debugger command. This was no longer true as of version 5.6.0. Type perl-de0 to enter this environment.[2] Let’s use this as a sandbox for testing Perl constructs: [2] There are many expressions other than 0 that would work equally well, of course. Perl just needs something innocuous to run. % perl -de 0 DB<1> $_ = ‘What_do*parens-in=split+do%again?’; DB<2> @a = split /(W+)/; 0 DB<3> x @a ‘What_do’ 1 ‘*’ 2 3 ‘parens’ ‘-’

Note: If you are looking for good and affordable webspace to host and run your servlet application check Virtualwebstudio servlet hosting services

Comments are closed.