t/op/grep.t using test.pl
[p5sagit/p5-mst-13.2.git] / pod / perlfaq3.pod
index b5f3562..6eea58b 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perlfaq3 - Programming Tools ($Revision: 1.51 $, $Date: 2005/08/10 15:56:39 $)
+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://www.focusresearch.com/gregor/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;
 
@@ -85,8 +84,14 @@ with File::Find which is part of the standard library.
     use File::Find;
     my @files;
 
-    find sub { push @files, $File::Find::name if -f _ && /\.pm$/ },
-         @INC;
+    find(
+      sub {
+       push @files, $File::Find::name
+               if -f $File::Find::name && /\.pm$/
+       },
+
+      @INC
+      );
 
        print join "\n", @files;
 
@@ -105,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?
 
@@ -772,30 +790,26 @@ You probably won't see much of a speed increase either, since most
 solutions simply bundle a Perl interpreter in the final product
 (but see L<How can I make my Perl program run faster?>).
 
-The Perl Archive Toolkit (http://par.perl.org/index.cgi) is
-Perl's analog to Java's JAR.  It's freely available and on
-CPAN (http://search.cpan.org/dist/PAR/).
+The Perl Archive Toolkit ( http://par.perl.org/index.cgi ) is Perl's
+analog to Java's JAR.  It's freely available and on CPAN (
+http://search.cpan.org/dist/PAR/ ).
 
-The B::* namespace, often called "the Perl compiler", but is really a
-way for Perl programs to peek at its innards rather than create
-pre-compiled versions of your program.  However. the B::Bytecode
-module can turn your script  into a bytecode format that could be
-loaded later by the ByteLoader module and executed as a regular Perl
-script.
+The B::* namespace, often called "the Perl compiler", but is really a way
+for Perl programs to peek at its innards rather than create pre-compiled
+versions of your program.  However. the B::Bytecode module can turn your
+script  into a bytecode format that could be loaded later by the
+ByteLoader module and executed as a regular Perl script.
 
-There are also some commercial products that may work for
-you, although you have to buy a license for them.
+There are also some commercial products that may work for you, although
+you have to buy a license for them.
 
-The Perl Dev Kit
-(http://www.activestate.com/Products/Perl_Dev_Kit/) from
-ActiveState can "Turn your Perl programs into ready-to-run
+The Perl Dev Kit ( http://www.activestate.com/Products/Perl_Dev_Kit/ )
+from ActiveState can "Turn your Perl programs into ready-to-run
 executables for HP-UX, Linux, Solaris and Windows."
 
-Perl2Exe (http://www.indigostar.com/perl2exe.htm) is a
-command line program for converting perl scripts to
-executable files.  It targets both Windows and unix
-platforms.
-
+Perl2Exe ( http://www.indigostar.com/perl2exe.htm ) is a command line
+program for converting perl scripts to executable files.  It targets both
+Windows and unix platforms.
 
 =head2 How can I compile Perl into Java?
 
@@ -923,12 +937,11 @@ guides and references in L<perlfaq9> or in the CGI MetaFAQ:
 
 A good place to start is L<perltoot>, and you can use L<perlobj>,
 L<perlboot>, L<perltoot>, L<perltooc>, and L<perlbot> for reference.
-(If you are using really old Perl, you may not have all of these,
-try http://www.perldoc.com/ , but consider upgrading your perl.)
 
 A good book on OO on Perl is the "Object-Oriented Perl"
-by Damian Conway from Manning Publications,
-http://www.manning.com/Conway/index.html
+by Damian Conway from Manning Publications, or "Learning Perl
+References, Objects, & Modules" by Randal Schwartz and Tom
+Phoenix from O'Reilly Media.
 
 =head2 Where can I learn about linking C with Perl?
 
@@ -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