Perl
  Home arrow Perl arrow Page 4 - 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? 
Google.com  
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 - A Watchful Eye
    ( Page 4 of 6 )

    You can set a watch-expression (an expression which triggers a halt if its value changes) with the "w" command, as in the following example:


    DB<1> w $count
    DB<<3>> L
    Watch-expressions:
    $count

    Now that the watch-expression has been set, you can see how it works by writing some code to alter the value of the $count variable. The debugger will display a message every time the variable's value changes.


    DB<2> for ($count=0; $count<=10; $count++) { print "Hello!"; };
    Watchpoint 0: $count changed:
    old value: undef
    new value: '0'
    DB<<3>> s
    main::((eval 13)[/usr/lib/perl5/5.8.0/perl5db.pl:17]:2):
    2: for ($count=0; $count<=10; $count++) { print "Hello!"; };;
    DB<<3>>
    Watchpoint 0: $count changed:
    old value: '0'
    new value: '1'
    main::((eval 13)[/usr/lib/perl5/5.8.0/perl5db.pl:17]:2):
    2: for ($count=0; $count<=10; $count++) { print "Hello!"; };;
    DB<<3>> Hello!
    main::((eval 13)[/usr/lib/perl5/5.8.0/perl5db.pl:17]:2):
    2: for ($count=0; $count<=10; $count++) { print "Hello!"; };;
    DB<<3>> s
    Watchpoint 0: $count changed:
    old value: '1'
    new value: '2'
    for ($count=0; $count<=10; $count++) { print "Hello!"; };

    Watch-expressions can be deleted with the "W" command; either specify the expression


    DB<<3>> W $count

    or delete all currently-set expressions with the * wildcard.


    DB<<4>> W *
    Deleting all watch expressions ...

    Note that adding watch-expressions can result in a performance penalty, so you should try and restrict yourself to not more than three or four at any given time.



     
     
    >>> 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 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek