t/op/grep.t using test.pl
[p5sagit/p5-mst-13.2.git] / pod / perlfaq3.pod
index 6e2f331..6eea58b 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perlfaq3 - Programming Tools ($Revision: 1.54 $, $Date: 2005/11/17 17:22:02 $)
+perlfaq3 - Programming Tools ($Revision: 3606 $)
 
 =head1 DESCRIPTION
 
@@ -85,11 +85,11 @@ with File::Find which is part of the standard library.
     my @files;
 
     find(
-      sub { 
-       push @files, $File::Find::name 
-               if -f $File::Find::name && /\.pm$/ 
+      sub {
+       push @files, $File::Find::name
+               if -f $File::Find::name && /\.pm$/
        },
-       
+
       @INC
       );
 
@@ -110,28 +110,41 @@ perl finds it.
 
 =head2 How do I debug my Perl programs?
 
-Have you tried C<use warnings> or used C<-w>?  They enable warnings
-to detect dubious practices.
+(contributed by brian d foy)
+
+Before you do anything else, you can help yourself by ensuring that
+you let Perl tell you about problem areas in your code. By turning
+on warnings and strictures, you can head off many problems before 
+they get too big. You can find out more about these in L<strict>
+and L<warnings>.
+
+       #!/usr/bin/perl
+       use strict;
+       use warnings;
+       
+Beyond that, the simplest debugger is the C<print> function. Use it
+to look at values as you run your program:
+
+       print STDERR "The value is [$value]\n";
 
-Have you tried C<use strict>?  It prevents you from using symbolic
-references, makes you predeclare any subroutines that you call as bare
-words, and (probably most importantly) forces you to predeclare your
-variables with C<my>, C<our>, or C<use vars>.
+The C<Data::Dumper> module can pretty-print Perl data structures:
 
-Did you check the return values of each and every system call?  The operating
-system (and thus Perl) tells you whether they worked, and if not
-why.
+       use Data::Dumper( Dump );
+       print STDERR "The hash is " . Dump( \%hash ) . "\n";
+       
+Perl comes with an interactive debugger, which you can start with the
+C<-d> switch. It's fully explained in L<perldebug>.
 
-  open(FH, "> /etc/cantwrite")
-    or die "Couldn't write to /etc/cantwrite: $!\n";
+If you'd like a graphical user interface and you have Tk, you can use
+C<ptkdb>. It's on CPAN and available for free.
 
-Did you read L<perltrap>?  It's full of gotchas for old and new Perl
-programmers and even has sections for those of you who are upgrading
-from languages like I<awk> and I<C>.
+If you need something much more sophisicated and controllable, Leon
+Brocard's Devel::ebug (which you can call with the -D switch as -Debug)
+gives you the programmatic hooks into everything you need to write your
+own (without too much pain and suffering).
 
-Have you tried the Perl debugger, described in L<perldebug>?  You can
-step through your program and see what it's doing and thus work out
-why what it's doing isn't what it should be doing.
+You can also use a commercial debugger such as Affrus (Mac OS X), Komodo
+from Activestate (Windows and Mac OS X), or EPIC (most platforms).
 
 =head2 How do I profile my Perl programs?
 
@@ -941,7 +954,7 @@ solved their problems.
 
 You might not need all the power of XS. The Inline::C module lets
 you put C code directly in your Perl source. It handles all the
-magic to make it work. You still have to learn at least some of 
+magic to make it work. You still have to learn at least some of
 the perl API but you won't have to deal with the complexity of the
 XS support files.
 
@@ -975,9 +988,17 @@ This module (part of the standard Perl distribution) is designed to
 write a Makefile for an extension module from a Makefile.PL.  For more
 information, see L<ExtUtils::MakeMaker>.
 
+=head1 REVISION
+
+Revision: $Revision: 3606 $
+
+Date: $Date: 2006-03-06 12:05:47 +0100 (lun, 06 mar 2006) $
+
+See L<perlfaq> for source control details and availability.
+
 =head1 AUTHOR AND COPYRIGHT
 
-Copyright (c) 1997-2005 Tom Christiansen, Nathan Torkington, and
+Copyright (c) 1997-2006 Tom Christiansen, Nathan Torkington, and
 other authors as noted. All rights reserved.
 
 This documentation is free; you can redistribute it and/or modify it