Invoking Perl debugger so that it runs until first breakpoint

When I invoke my Perl debugger with perl -d, the debugger starts, but it does not execute any code until I press n (next) or c (continue).

Is there anyway to invoke the debugger and have it run through the code by default until it hits a breakpoint?

If so, is there any statement that I can use in my code as a breakpoint to have the debugger stop when it hits it?


Here is what I have in my .perldb file:

print "Reading ~/.perldb options.\n";
push @DB::typeahead, "c";

Here is my file:

use strict;
use warnings;

print "Hello world.\n"; 
print "How are you?";

Here is the debugging session from running: perl -d

Reading ~/.perldb options.
Hello world
main::(       print "How are you?";
auto(-1)  DB<1> c
Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.  
  DB<1> v
9563    9564    
9565    sub at_exit {
9566==>     "Debugged program terminated.  Use `q' to quit or `R' to restart.";
9567    }
9569    package DB;    # Do not trace this 1; below!

In other words, my debugger skips print "How are you?", and instead stops once the program finishes, which is not what I want.

What I want is have the debugger run my code without stopping anywhere (nor at the beginning, nor at the end of my script), unless I explicitly have a $DB::single=1; statement, in which case I would like it to stop before running the next line. Any ways to do this?

For reference, I am using:

$perl --version 

This is perl 5, version 14, subversion 1 (v5.14.1) built for x86_64-linux



$DB::single = 1;

before any statement to set a permanent breakpoint in your code. This works with compile-time code, too, and may be the only good way to set a breakpoint during the compile phase.

To have the debugger automatically start your code, you can manipulate the @DB::typeahead array in either a .perldb file or in a compile-time (BEGIN) block in your code. For example:

# .perldb file
push @DB::typeahead, "c";


BEGIN { push @DB::typeahead, "p 'Hello!'", "c" }
$DB::single = 1;
$x = want_to_stop_here();

There is also a "NonStop" option that you could set in .perldb or in the PERLDB_OPTS environment variable:

PERLDB_OPTS=NonStop perl -d

All of this (and much more) is discussed deep in the bowels of perldebug and


To address the issues raised in the most recent update. Use the following in ./perldb:

print "Reading ~/.perldb options.\n";
push @DB::typeahead, "c";

Need Your Help

How to save Graphics object as image in C#?

c# image graphics

I have panel and various controls on it. I would like to save an image of this panel into a file, how can I do this ?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.