t/op/grep.t using test.pl
[p5sagit/p5-mst-13.2.git] / pod / perlfaq3.pod
index 032fc67..6eea58b 100644 (file)
@@ -1,6 +1,6 @@
 =head1 NAME
 
-perlfaq3 - Programming Tools ($Revision: 1.48 $, $Date: 2005/04/22 19:04:48 $)
+perlfaq3 - Programming Tools ($Revision: 3606 $)
 
 =head1 DESCRIPTION
 
@@ -31,7 +31,7 @@ A crude table of contents for the Perl manpage set is found in L<perltoc>.
 =head2 How can I use Perl interactively?
 
 The typical approach uses the Perl debugger, described in the
-perldebug(1) manpage, on an ``empty'' program, like this:
+perldebug(1) manpage, on an "empty" program, like this:
 
     perl -de 42
 
@@ -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:
 
-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>.
+       print STDERR "The value is [$value]\n";
 
-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.
+The C<Data::Dumper> module can pretty-print Perl data structures:
 
-  open(FH, "> /etc/cantwrite")
-    or die "Couldn't write to /etc/cantwrite: $!\n";
+       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>.
 
-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'd like a graphical user interface and you have Tk, you can use
+C<ptkdb>. It's on CPAN and available for free.
 
-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.
+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).
+
+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?
 
@@ -202,13 +220,11 @@ documents, as does enscript at http://people.ssh.fi/mtr/genscript/ .
 
 =head2 Is there a ctags for Perl?
 
-Recent versions of ctags do much more than older versions did.
-EXUBERANT CTAGS is available from http://ctags.sourceforge.net/
-and does a good job of making tags files for perl code.
+(contributed by brian d foy)
+
+Exuberent ctags supports Perl: http://ctags.sourceforge.net/
 
-There is also a simple one at
-http://www.cpan.org/authors/id/TOMC/scripts/ptags.gz which may do
-the trick.  It can be easy to hack this into what you want.
+You might also try pltags: http://www.mscha.com/pltags.zip
 
 =head2 Is there an IDE or Windows Perl Editor?
 
@@ -225,68 +241,91 @@ order of preference):
 
 =item Eclipse
 
+http://e-p-i-c.sf.net/
+
 The Eclipse Perl Integration Project integrates Perl
 editing/debugging with Eclipse.
 
-The website for the project is http://e-p-i-c.sf.net/
+=item Enginsite
+
+http://www.enginsite.com/
+
+Perl Editor by EngInSite is a complete integrated development
+environment (IDE) for creating, testing, and  debugging  Perl scripts;
+the tool runs on Windows 9x/NT/2000/XP or later.
 
 =item Komodo
 
+http://www.ActiveState.com/Products/Komodo/
+
 ActiveState's cross-platform (as of October 2004, that's Windows, Linux,
 and Solaris), multi-language IDE has Perl support, including a regular expression
-debugger and remote debugging
-( http://www.ActiveState.com/Products/Komodo/ ).
+debugger and remote debugging.
 
 =item Open Perl IDE
 
-( http://open-perl-ide.sourceforge.net/ )
+http://open-perl-ide.sourceforge.net/
+
 Open Perl IDE is an integrated development environment for writing
 and debugging Perl scripts with ActiveState's ActivePerl distribution
 under Windows 95/98/NT/2000.
 
 =item OptiPerl
 
-( http://www.optiperl.com/ ) is a Windows IDE with simulated CGI
-environment, including debugger and syntax highlighting editor.
+http://www.optiperl.com/
+
+OptiPerl is a Windows IDE with simulated CGI environment, including
+debugger and syntax highlighting editor.
 
 =item PerlBuilder
 
-( http://www.solutionsoft.com/perl.htm ) is an integrated development
-environment for Windows that supports Perl development.
+http://www.solutionsoft.com/perl.htm
+
+PerlBuidler is an integrated development environment for Windows that
+supports Perl development.
 
 =item visiPerl+
 
-( http://helpconsulting.net/visiperl/ )
+http://helpconsulting.net/visiperl/
+
 From Help Consulting, for Windows.
 
 =item Visual Perl
 
-( http://www.activestate.com/Products/Visual_Perl/ )
+http://www.activestate.com/Products/Visual_Perl/
+
 Visual Perl is a Visual Studio.NET plug-in from ActiveState.
 
+=item Zeus
+
+http://www.zeusedit.com/lookmain.html
+
+Zeus for Window is another Win32 multi-language editor/IDE
+that comes with support for Perl:
 
 =back
 
-For editors: if you're on Unix you probably have vi or a vi clone already,
-and possibly an emacs too, so you may not need to download anything.
-In any emacs the cperl-mode (M-x cperl-mode) gives you perhaps the
-best available Perl editing mode in any editor.
-
-If you are using Windows, you can use any editor that lets
-you work with plain text, such as NotePad or WordPad.  Word
-processors, such as Microsoft Word or WordPerfect, typically
-do not work since they insert all sorts of behind-the-scenes
-information, although some allow you to save files as "Text
-Only". You can also download text editors designed
-specifically for programming, such as Textpad
-( http://www.textpad.com/ ) and UltraEdit
-( http://www.ultraedit.com/ ), among others.
-
-If you are using MacOS, the same concerns apply.  MacPerl
-(for Classic environments) comes with a simple editor.
-Popular external editors are BBEdit ( http://www.bbedit.com/ )
-or Alpha ( http://www.his.com/~jguyer/Alpha/Alpha8.html ). MacOS X users can
-use Unix editors as well.
+For editors: if you're on Unix you probably have vi or a vi clone
+already, and possibly an emacs too, so you may not need to download
+anything. In any emacs the cperl-mode (M-x cperl-mode) gives you
+perhaps the best available Perl editing mode in any editor.
+
+If you are using Windows, you can use any editor that lets you work
+with plain text, such as NotePad or WordPad.  Word processors, such as
+Microsoft Word or WordPerfect, typically do not work since they insert
+all sorts of behind-the-scenes information, although some allow you to
+save files as "Text Only". You can also download text editors designed
+specifically for programming, such as Textpad (
+http://www.textpad.com/ ) and UltraEdit ( http://www.ultraedit.com/ ),
+among others.
+
+If you are using MacOS, the same concerns apply.  MacPerl (for Classic
+environments) comes with a simple editor. Popular external editors are
+BBEdit ( http://www.bbedit.com/ ) or Alpha (
+http://www.his.com/~jguyer/Alpha/Alpha8.html ). MacOS X users can use
+Unix editors as well. Neil Bowers (the man behind Geekcruises) has a
+list of Mac editors that can handle Perl (
+http://www.neilbowers.org/macperleditors.html ).
 
 =over 4
 
@@ -407,7 +446,7 @@ no 32k limit).
 
 =item Affrus
 
-is a full Perl development enivornment with full debugger support
+is a full Perl development environment with full debugger support
 ( http://www.latenightsw.com ).
 
 =item Alpha
@@ -481,8 +520,8 @@ on optimization, too.  Advice on benchmarking boils down to: benchmark
 and profile to make sure you're optimizing the right part, look for
 better algorithms instead of microtuning your code, and when all else
 fails consider just buying faster hardware.  You will probably want to
-read the answer to the earlier question ``How do I profile my Perl
-programs?'' if you haven't done so already.
+read the answer to the earlier question "How do I profile my Perl
+programs?" if you haven't done so already.
 
 A different approach is to autoload seldom-used Perl code.  See the
 AutoSplit and AutoLoader modules in the standard distribution for
@@ -696,19 +735,10 @@ care.
 
 See http://www.cpan.org/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/ .
 
-A non-free, commercial product, ``The Velocity Engine for Perl'',
-(http://www.binevolve.com/ or http://www.binevolve.com/velocigen/ )
-might also be worth looking at.  It will allow you to increase the
-performance of your Perl programs, running programs up to 25 times
-faster than normal CGI Perl when running in persistent Perl mode or 4
-to 5 times faster without any modification to your existing CGI
-programs. Fully functional evaluation copies are available from the
-web site.
-
 =head2 How can I hide the source for my Perl program?
 
 Delete it. :-) Seriously, there are a number of (mostly
-unsatisfactory) solutions with varying levels of ``security''.
+unsatisfactory) solutions with varying levels of "security".
 
 First of all, however, you I<can't> take away read permission, because
 the source code has to be readable in order to be compiled and
@@ -743,9 +773,9 @@ unique to Perl.
 If you're concerned about people profiting from your code, then the
 bottom line is that nothing but a restrictive license will give you
 legal security.  License your software and pepper it with threatening
-statements like ``This is unpublished proprietary software of XYZ Corp.
+statements like "This is unpublished proprietary software of XYZ Corp.
 Your access to it does not give you permission to use it blah blah
-blah.''  We are not lawyers, of course, so you should see a lawyer if
+blah."  We are not lawyers, of course, so you should see a lawyer if
 you want to be sure your license's wording will stand up in court.
 
 =head2 How can I compile my Perl program into byte code or C?
@@ -760,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?
 
@@ -802,7 +828,7 @@ For OS/2 just use
     extproc perl -S -your_switches
 
 as the first line in C<*.cmd> file (C<-S> due to a bug in cmd.exe's
-`extproc' handling).  For DOS one should first invent a corresponding
+"extproc" handling).  For DOS one should first invent a corresponding
 batch file and codify it in C<ALTERNATE_SHEBANG> (see the
 F<dosish.h> file in the source distribution for more information).
 
@@ -900,9 +926,9 @@ There is no general solution to all of this.  It is a mess.
 
 For modules, get the CGI or LWP modules from CPAN.  For textbooks,
 see the two especially dedicated to web stuff in the question on
-books.  For problems and questions related to the web, like ``Why
-do I get 500 Errors'' or ``Why doesn't it run from the browser right
-when it runs fine on the command line'', see the troubleshooting
+books.  For problems and questions related to the web, like "Why
+do I get 500 Errors" or "Why doesn't it run from the browser right
+when it runs fine on the command line", see the troubleshooting
 guides and references in L<perlfaq9> or in the CGI MetaFAQ:
 
        http://www.perl.org/CGI_MetaFAQ.html
@@ -911,14 +937,13 @@ 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? [h2xs, xsubpp]
+=head2 Where can I learn about linking C with Perl?
 
 If you want to call C from Perl, start with L<perlxstut>,
 moving on to L<perlxs>, L<xsubpp>, and L<perlguts>.  If you want to
@@ -927,6 +952,12 @@ L<perlguts>.  Don't forget that you can learn a lot from looking at
 how the authors of existing extension modules wrote their code and
 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
+the perl API but you won't have to deal with the complexity of the
+XS support files.
+
 =head2 I've read perlembed, perlguts, etc., but I can't embed perl in my C program; what am I doing wrong?
 
 Download the ExtUtils::Embed kit from CPAN and run `make test'.  If
@@ -957,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