t/op/grep.t using test.pl
[p5sagit/p5-mst-13.2.git] / pod / perlfaq3.pod
index 02e15b7..6eea58b 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perlfaq3 - Programming Tools ($Revision: 1.52 $, $Date: 2005/10/13 19:43:13 $)
+perlfaq3 - Programming Tools ($Revision: 3606 $)
 
 =head1 DESCRIPTION
 
@@ -42,12 +42,12 @@ operations typically found in symbolic debuggers.
 
 =head2 Is there a Perl shell?
 
-The psh (Perl sh) is currently at version 1.8. The Perl Shell is a
-shell that combines the interactive nature of a Unix shell with the
-power of Perl. The goal is a full featured shell that behaves as
-expected for normal shell activity and uses Perl syntax and
-functionality for control-flow statements and other things.
-You can get psh at http://sourceforge.net/projects/psh/ .
+The psh (Perl sh) is currently at version 1.8. The Perl Shell is a shell
+that combines the interactive nature of a Unix shell with the power of
+Perl. The goal is a full featured shell that behaves as expected for
+normal shell activity and uses Perl syntax and functionality for
+control-flow statements and other things. You can get psh at
+http://sourceforge.net/projects/psh/ .
 
 Zoidberg is a similar project and provides a shell written in perl,
 configured in perl and operated in perl. It is intended as a login shell
@@ -55,17 +55,16 @@ and development environment. It can be found at http://zoidberg.sf.net/
 or your local CPAN mirror.
 
 The Shell.pm module (distributed with Perl) makes Perl try commands
-which aren't part of the Perl language as shell commands.  perlsh
-from the source distribution is simplistic and uninteresting, but
-may still be what you want.
+which aren't part of the Perl language as shell commands.  perlsh from
+the source distribution is simplistic and uninteresting, but may still
+be what you want.
 
 =head2 How do I find which modules are installed on my system?
 
-You can use the ExtUtils::Installed module to show all
-installed distributions, although it can take awhile to do
-its magic.  The standard library which comes with Perl just
-shows up as "Perl" (although you can get those with
-Module::CoreList).
+You can use the ExtUtils::Installed module to show all installed
+distributions, although it can take awhile to do its magic.  The
+standard library which comes with Perl just shows up as "Perl" (although
+you can get those with Module::CoreList).
 
        use ExtUtils::Installed;
 
@@ -86,11 +85,15 @@ 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
-    );
+      );
 
-    print "$_\n" for @files;
+       print join "\n", @files;
 
 If you simply need to quickly check to see if a module is
 available, you can check for its documentation.  If you can
@@ -107,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?
 
@@ -938,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.
 
@@ -972,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