Perl
  Home arrow Perl arrow Page 3 - Using The Perl Debugger
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PERL

Using The Perl Debugger
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 27
    2003-06-25


    Table of Contents:
  • Using The Perl Debugger
  • Step By Step
  • Breaking Free
  • A Watchful Eye
  • Acts Of Madness
  • Test Drive

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Using The Perl Debugger - Breaking Free
    ( Page 3 of 6 )

    The Perl debugger also allows you to define a variety of triggers within your script; these triggers - breakpoints, watch-expressions and actions - come in handy when you need to keep an eye on the values of different variables, since they can be set to automatically notify you in the event of a change.

    Breakpoints can be set with the "b" command, which may be followed with either a subroutine name or line number. The following line sets a breakpoint at the first line of the subroutine install_driver() of the DBI
    module:


    DB<14> b DBI::install_driver
    DB<15> L
    /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/DBI.pm:
    576: my $class = shift;
    break if (1)

    When the debugger reaches this line, it will halt and wait for a new command.


    DB<15> n
    main::(mailer.pl:12): my $id = $ARGV[0];
    DB<15> n
    main::(mailer.pl:16): my $dbh =
    DBI->connect("DBI:mysql:database=db198;host=localhost", "root",
    DBI->"secret",
    {'RaiseError' => 1}) or die ("Cannot connect to database");
    DB<15> n DBI::install_driver(/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
    /DBI.pm:576):
    576: my $class = shift;
    DB<15>

    You can set a one-time breakpoint with the "c" command; this command continues executing the script until the breakpoint is reached, at which point it stops and waits for a command.


    DB<1> c 19
    main::(mailer.pl:19): my $sendmail = "/usr/sbin/sendmail -t";

    You can even place a breakpoint within your Perl code, simply by adding the line


    $DB::single=1;

    or


    $DB::single=2;

    at the appropriate point in your script. When the debugger encounters this statement while running the script, it will automatically halt and wait for a new command.

    You can delete breakpoints with the "B" command, which needs either a line number


    DB<8> B 19

    or the * wildcard to delete all breakpoints.


    DB<9> B *
    Deleting all breakpoints...



     
     
    >>> More Perl Articles          >>> More By icarus, (c) Melonfire
     

       

    PERL ARTICLES

    - More Perl Bits
    - Perl, Bit by Bit
    - Basic Charting with Perl
    - Using Getopt::Long: More Command Line Option...
    - Command Line Options in Perl: Using Getopt::...
    - Web Access with LWP
    - More Templating Tools for Perl
    - Site Layout with Perl Templating Tools
    - Build a Perl RSS Aggregator with Templating ...
    - Looping, Security, and Templating Tools
    - Perl: Bon Voyage Lists and Hashes
    - Templating Tools
    - Perl: Number Crunching
    - Perl Debuggers in Detail
    - Debugging Perl





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    Stay green...Green IT