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

 
Developer Updates  
Free Website Content 
IBM Developerworks
 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: 4 stars4 stars4 stars4 stars4 stars / 21
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    PCmover - $15 Off with Coupon Code CJPH7Q

    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

    - Perl: A Continuing Look at Hashes and Multid...
    - Perl: Another Round with Hashes
    - Perl Hashes
    - Perl Lists: A Final Look at List::Util
    - Perl Lists: Utilizing List::Util
    - Perl Lists: The Split() Function
    - SQL and CGI with Perl and DBI
    - Perl Lists: More Functions and Operators
    - SELECT Queries and Perl
    - Perl Lists: More on Manipulation
    - Creating a Database with Perl and DBI
    - Perl: Sailing the List(less) Seas
    - Perl and DBI
    - Perl: Concatenating Text and More
    - Perl Text: Quoting Without Quote Marks

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway