cvs commit: perlfaq glossary.pod perlfaq.pod perlfaq2.pod perlfaq3.pod perlfaq4.pod perlfaq5.pod perlfaq8.pod perlfaq9.pod

[email protected] (brian d foy) 30 Dec 2005 15:04:09 -0000
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     05/12/30 07:04:08

  Modified:    .        glossary.pod perlfaq.pod perlfaq2.pod perlfaq3.pod
                        perlfaq4.pod perlfaq5.pod perlfaq8.pod perlfaq9.pod
  Log:
  * perlfaq4: How do I expand function calls in a string?
      + Added Interpolation.pm example
  
  * perlfaq8: How do I do fancy stuff with the keyboard/screen/mouse?
      + Modified reference to other answers so answer could stand
      alone (in general, "below" is the wrong word to use because
      you don't actually know where in space the reference is)
  
  * All other files: cleaned up whitespace.
  
  Revision  Changes    Path
  1.4       +62 -62    perlfaq/glossary.pod
  
  Index: glossary.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/glossary.pod,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- glossary.pod	4 Dec 2003 07:50:26 -0000	1.3
  +++ glossary.pod	30 Dec 2005 15:04:07 -0000	1.4
  @@ -24,11 +24,11 @@
   a chapter in the Programming Perl book.  Each Apocalypse is followed
   by an Exegesis.
   
  -=head2 blat 
  +=head2 blat
   
  -To write out an entire file in one step 
  +To write out an entire file in one step
   
  -=head2 Camel book 
  +=head2 Camel book
   
   Programming Perl published by O'Reilly & Associates, which has a camel
   on the cover.  The first edition has a pink spine, and is known as
  @@ -41,20 +41,20 @@
   general purpose interface that can be used with any programming
   language, including Perl.  See also C<CGI.pm> and C<mod_perl>.
   
  -=head2 CGI.pm 
  +=head2 CGI.pm
   
   Standard Perl module that handles HTML form interaction, written
   by Lincoln Stein.   It is included in the standard Perl distribution.
   
  -=head2 clpm 
  +=head2 clpm
   
  -comp.lang.perl.misc, a usenet newsgroup. 
  +comp.lang.perl.misc, a usenet newsgroup.
   
   =head2 The Cookbook
   
   The Perl Cookbook.  See also The Ram Book.
   
  -=head2 CPAN 
  +=head2 CPAN
   
   The Comprehensive Perl Archive Network, modeled after CTAN, the
   Comprehensive TeX Archive Network.  CPAN is a central repository for
  @@ -78,17 +78,17 @@
   GNU toolchain.  A very popular technique for installing Perl on Windows
   systems.
   
  -=head2 DBD 
  +=head2 DBD
   
   A DataBase Driver for DBI.  The DBD provides the connection between a
   particular database server product (e.g. Oracle) and the abstract
   interface.  To change database products (e.g. from mysql to Oracle),
  -one simply uses a different DBD. 
  +one simply uses a different DBD.
   
  -=head2 DBI 
  +=head2 DBI
   
   Perl's abstract DataBase Interface which supports any database product
  -with a database driver (DBD) 
  +with a database driver (DBD)
   
   =head2 Exegesis
   
  @@ -115,9 +115,9 @@
   Mastering Regular Expressions, 2nd Ed, published by O'Reilly &
   Associates.
   
  -=head2 HFB 
  +=head2 HFB
   
  -Happy Fun Ball - Elaine Ashton. 
  +Happy Fun Ball - Elaine Ashton.
   
   =head2 Inline
   
  @@ -126,24 +126,24 @@
   a cleaner and simpler way to interface with C programs, compared to h2xs
   or SWIG.
   
  -=head2 JAPH 
  +=head2 JAPH
   
  -[1] "Just another Perl hacker" - popularized by Randal L. Schwartz. 
  +[1] "Just another Perl hacker" - popularized by Randal L. Schwartz.
   
   [2] A small Perl program that prints the phrase "Just Another Perl
   Hacker" using some combination of possibly obscure Perl features.
   
  -=head2 Llama book 
  +=head2 Llama book
   
   This is Learning Perl published by O'Reilly & Associates, which has a
   llama on the cover.  The first edition has a pink spine, and is known
  -as "the pink llama". The second and third editions have a blue spine and 
  +as "the pink llama". The second and third editions have a blue spine and
   are known as "llama2" and "llama3".
   
  -=head2 LWP 
  +=head2 LWP
   
   Library for interfacing with the World Wide Web from Perl.  This
  -distribution provides many modules for interacting with HTTP, FTP, and 
  +distribution provides many modules for interacting with HTTP, FTP, and
   email.  Look for C<Bundle::LWP> on CPAN.
   
   =head2 Mason
  @@ -151,10 +151,10 @@
   The C<HTML::Mason> module, a Perl framework for dynamic web development.
   See http://www.masonhq.com/
   
  -=head2 mod_perl 
  +=head2 mod_perl
   
   The Apache server plug-in that embeds a perl in the web server for
  -super-fast performance and increased flexibility. 
  +super-fast performance and increased flexibility.
   
   =head2 Nutty Camel
   
  @@ -170,30 +170,30 @@
   developed since the mid 1990s and are well known for containing a
   litany of security bugs.
   
  -=head2 O'Reilly book covers 
  +=head2 O'Reilly book covers
   
   In general, O'Reilly books have animals on the covers (although not
   for Java or all Unix books).  The books are often referred to by the
   animal on their cover.  If someone says something like "the Ram book",
  -he is referring to an O'Reilly book. 
  +he is referring to an O'Reilly book.
   
  -=head2 ORA 
  +=head2 ORA
   
  -O'Reilly & Associates. 
  +O'Reilly & Associates.
   
   =head2 OSCON
   
   Open Source Conference.  This conference encompasses many others,
   including TPC, and is run by O'Reilly & Associates.
   
  -=head2 OSS 
  +=head2 OSS
   
   Open Source Software.  Perl is open source and is often mentioned into
  -relationship to the OSS movement 
  +relationship to the OSS movement
   
  -=head2 p5p 
  +=head2 p5p
   
  -See perl5-porters. 
  +See perl5-porters.
   
   =head2 PAR
   
  @@ -205,29 +205,29 @@
   Parrot is a virtual machine used to efficiently execute bytecode
   for interpreted languages - specifically, Perl 6.
   
  -=head2 PAUSE 
  +=head2 PAUSE
   
   Perl Authors Upload Server - how software gets into CPAN.  See
  -http://www.cpan.org/modules/04pause.html. 
  +http://www.cpan.org/modules/04pause.html.
   
  -=head2 Perl 
  +=head2 Perl
   
   The language itself, as opposed to the interpreter, "perl", with a
  -lowercase "p". 
  +lowercase "p".
   
  -=head2 perl 
  +=head2 perl
   
   The program which interprets Perl and makes the computer do what it
  -says. 
  +says.
   
  -=head2 Perl4 
  +=head2 Perl4
   
   A dead camel carcass.  This is the version of Perl that pre-dated the
   current major release.  It should not be used for any new development.
   
  -=head2 perl5-porters 
  +=head2 perl5-porters
   
  -The mailing list for perl 5 developers. 
  +The mailing list for perl 5 developers.
   
   =head2 perl6-internals
   
  @@ -238,9 +238,9 @@
   A livley list for the discussion of the Perl 6 language design.  Not
   for the faint of heart.
   
  -=head2 Perl5 
  +=head2 Perl5
   
  -The modern major release of Perl 
  +The modern major release of Perl
   
   =head2 Perl6
   
  @@ -268,17 +268,17 @@
   An electronically published Perl magazine supported and developed by the
   community.  http://www.theperlreview.com
   
  -=head2 pumpking 
  +=head2 pumpking
   
  -A Perl project coordinator 
  +A Perl project coordinator
   
  -=head2 Ram book 
  +=head2 Ram book
   
  -This is The Perl Cookbook published by O'Reilly & Associates. 
  +This is The Perl Cookbook published by O'Reilly & Associates.
   
  -=head2 regex 
  +=head2 regex
   
  -A regular expression. 
  +A regular expression.
   
   =head2 regexp
   
  @@ -286,25 +286,25 @@
   
   =head2 slurp
   
  -to read in an entire file in one step 
  +to read in an entire file in one step
   
   
  -=head2 SWIG 
  +=head2 SWIG
   
  -An interface for allowing Perl to use C/C++ libraries and code. 
  +An interface for allowing Perl to use C/C++ libraries and code.
   
  -=head2 TMTOWTDI 
  +=head2 TMTOWTDI
   
   There's More Than One Way To Do It - a major philosophy in the design
   of Perl. Language constructs can be expressed in more than one way,
  -just as in natural language. 
  +just as in natural language.
   
  -=head2 Topaz 
  +=head2 Topaz
   
   An old, exploratory project by Chip Salzenberg to rewrite Perl in C++.
   This project predates the Perl6 project and is now dead.
   
  -=head2 TPC 
  +=head2 TPC
   
   The Perl Conference, hosted by O'Reilly & Associates.  It is held
   concurrently with OSCon.
  @@ -315,13 +315,13 @@
   growth and development of the Perl community.  Such projects include
   YAPC, Perl 6 and parrot, Perl Mongers, and PerlMonks.
   
  -=head2 TPI 
  +=head2 TPI
   
  -The Perl Institute (now defunct). 
  +The Perl Institute (now defunct).
   
  -=head2 TPJ 
  +=head2 TPJ
   
  -The Perl Journal. 
  +The Perl Journal.
   
   =head2 TPR
   
  @@ -338,14 +338,14 @@
   as well as many online Journals (blogs) of people in the Perl
   community.  http://use.perl.org
   
  -=head2 White Camel 
  +=head2 White Camel
   
   An award given out by Perl Mongers for significant nontechnical
  -contribution to the Perl community. 
  +contribution to the Perl community.
   
  -=head2 XS 
  +=head2 XS
   
  -An interface for allowing Perl to use C/C++ libraries and code. 
  +An interface for allowing Perl to use C/C++ libraries and code.
   
   =head2 YAS
   
  @@ -353,7 +353,7 @@
   Perl Foundation, and YAPC events worldwide.  YAS is a 501(c)(3)
   nonprofit organization in the USA.
   
  -=head2 YAPC 
  +=head2 YAPC
   
   Yet Another Perl Conference, created by Kevin Lenzo as a low-cost,
   less-lavish alternative to TPC.  There are several YAPC conferences held
  
  
  
  1.28      +2 -2      perlfaq/perlfaq.pod
  
  Index: perlfaq.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq.pod,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- perlfaq.pod	10 Nov 2005 00:36:18 -0000	1.27
  +++ perlfaq.pod	30 Dec 2005 15:04:07 -0000	1.28
  @@ -45,7 +45,7 @@
   
   =head1 Author and Copyright Information
   
  -Copyright (c) 1997-2005 Tom Christiansen, Nathan Torkington, and 
  +Copyright (c) 1997-2005 Tom Christiansen, Nathan Torkington, and
   other contributors noted in the answers.
   
   All rights reserved.
  
  
  
  1.37      +3 -3      perlfaq/perlfaq2.pod
  
  Index: perlfaq2.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq2.pod,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- perlfaq2.pod	18 Dec 2005 13:25:27 -0000	1.36
  +++ perlfaq2.pod	30 Dec 2005 15:04:07 -0000	1.37
  @@ -355,12 +355,12 @@
   	by Damian Conway
   	ISBN: 0-596-00173-8 [1st edition July 2005]
   	http://www.oreilly.com/catalog/perlbp/
  -	
  +
   	Higher Order Perl
   	by Mark-Jason Dominus
   	ISBN: 1558607013 [1st edition March 2005]
   	http://hop.perl.plover.com/
  -	
  +
   	Perl 6 Now: The Core Ideas Illustrated with Perl 5
   	by Scott Walters
   	ISBN 1-59059-395-2 [1st edition December 2004]
  
  
  
  1.55      +6 -6      perlfaq/perlfaq3.pod
  
  Index: perlfaq3.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq3.pod,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- perlfaq3.pod	17 Nov 2005 17:22:02 -0000	1.54
  +++ perlfaq3.pod	30 Dec 2005 15:04:07 -0000	1.55
  @@ -85,11 +85,11 @@
       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
         );
   
  @@ -941,7 +941,7 @@
   
   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.
   
  
  
  
  1.72      +31 -23    perlfaq/perlfaq4.pod
  
  Index: perlfaq4.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- perlfaq4.pod	23 Nov 2005 07:46:45 -0000	1.71
  +++ perlfaq4.pod	30 Dec 2005 15:04:07 -0000	1.72
  @@ -484,20 +484,20 @@
   give you the same time of day, only the day before.
   
   	use DateTime;
  -	
  +
   	my $yesterday = DateTime->now->subtract( days => 1 );
  -	
  +
   	print "Yesterday was $yesterday\n";
   
   You can also use the C<Date::Calc> module using its Today_and_Now
   function.
   
   	use Date::Calc qw( Today_and_Now Add_Delta_DHMS );
  -	
  +
   	my @date_time = Add_Delta_DHMS( Today_and_Now(), -1, 0, 0, 0 );
  -	
  +
   	print "@date\n";
  -	
  +
   Most people try to use the time rather than the calendar to figure out
   dates, but that assumes that days are twenty-four hours each.  For
   most people, there are two days a year when they aren't: the switch to
  @@ -589,11 +589,11 @@
   
   This is documented in L<perlref>, and although it's not the easiest
   thing to read, it does work. In each of these examples, we call the
  -function inside the braces of used to dereference a reference. If we
  +function inside the braces used to dereference a reference. If we
   have a more than one return value, we can construct and dereference an
   anonymous array. In this case, we call the function in list context.
   
  -    print "The time values are @{ [localtime] }.\n";
  +	print "The time values are @{ [localtime] }.\n";
   
   If we want to call the function in scalar context, we have to do a bit
   more work. We can really have any code we like inside the braces, so
  @@ -601,18 +601,26 @@
   that is up to you, and you can use code inside the braces.
   
   	print "The time is ${\(scalar localtime)}.\n"
  -	
  +
   	print "The time is ${ my $x = localtime; \$x }.\n";
  -	
  +
   If your function already returns a reference, you don't need to create
   the reference yourself.
   
   	sub timestamp { my $t = localtime; \$t }
  -	
  +
   	print "The time is ${ timestamp() }.\n";
  -	
  -In most cases, it is probably easier to simply use string
  -concatenation, which also forces scalar context.
  +
  +The C<Interpolation> module can also do a lot of magic for you. You can
  +specify a variable name, in this case C<E>, to set up a tied hash that
  +does the interpolation for you. It has several other methods to do this
  +as well.
  +
  +	use Interpolation E => 'eval';
  +	print "The time values are $E{localtime()}.\n";
  +
  +In most cases, it is probably easier to simply use string concatenation,
  +which also forces scalar context.
   
   	print "The time is " . localtime . ".\n";
   
  @@ -1277,7 +1285,7 @@
   list context.
   
   	my @matches = grep $_ eq $whatever, @array;
  -	
  +
   =head2 How do I compute the difference of two arrays?  How do I compute the intersection of two arrays?
   
   Use a hash.  Here's code to do both and more.  It assumes that
  @@ -1795,25 +1803,25 @@
   create a report which lists the keys in ASCIIbetical order.
   
   	my @keys = sort { $a cmp $b } keys %hash;
  -	
  +
   	foreach my $key ( @keys )
   		{
   		printf "%-20s %6d\n", $key, $hash{$value};
   		}
   
  -We could get more fancy in the C<sort()> block though. Instead of 
  +We could get more fancy in the C<sort()> block though. Instead of
   comparing the keys, we can compute a value with them and use that
  -value as the comparison.  
  +value as the comparison.
   
   For instance, to make our report order case-insensitive, we use
  -the C<\L> sequence in a double-quoted string to make everything 
  +the C<\L> sequence in a double-quoted string to make everything
   lowercase. The C<sort()> block then compares the lowercased
   values to determine in which order to put the keys.
   
   	my @keys = sort { "\L$a" cmp "\L$b" } keys %hash;
  -	
  +
   Note: if the computation is expensive or the hash has many elements,
  -you may want to look at the Schwartzian Transform to cache the 
  +you may want to look at the Schwartzian Transform to cache the
   computation results.
   
   If we want to sort by the hash value instead, we use the hash key
  @@ -1825,8 +1833,8 @@
   From there we can get more complex. If the hash values are the same,
   we can provide a secondary sort on the hash key.
   
  -	my @keys = sort { 
  -		$hash{$a} <=> $hash{$b} 
  +	my @keys = sort {
  +		$hash{$a} <=> $hash{$b}
   			or
   		"\L$a" cmp "\L$b"
   		} keys %hash;
  
  
  
  1.41      +2 -2      perlfaq/perlfaq5.pod
  
  Index: perlfaq5.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq5.pod,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- perlfaq5.pod	10 Nov 2005 16:06:07 -0000	1.40
  +++ perlfaq5.pod	30 Dec 2005 15:04:07 -0000	1.41
  @@ -516,7 +516,7 @@
   Unless you have a particular reason to use the two argument form you
   should use the three argument form of open() which does not treat any
   charcters in the filename as special.
  -     
  +
   	open FILE, "<", "  file  ";  # filename is "   file   "
   	open FILE, ">", ">file";     # filename is ">file"
   
  
  
  
  1.26      +12 -11    perlfaq/perlfaq8.pod
  
  Index: perlfaq8.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq8.pod,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- perlfaq8.pod	4 Jun 2005 04:12:40 -0000	1.25
  +++ perlfaq8.pod	30 Dec 2005 15:04:07 -0000	1.26
  @@ -35,25 +35,26 @@
   
   =item Keyboard
   
  -    Term::Cap			Standard perl distribution
  -    Term::ReadKey		CPAN
  -    Term::ReadLine::Gnu		CPAN
  -    Term::ReadLine::Perl	CPAN
  -    Term::Screen		CPAN
  +	Term::Cap               Standard perl distribution
  +	Term::ReadKey           CPAN
  +	Term::ReadLine::Gnu     CPAN
  +	Term::ReadLine::Perl    CPAN
  +	Term::Screen            CPAN
   
   =item Screen
   
  -    Term::Cap			Standard perl distribution
  -    Curses			CPAN
  -    Term::ANSIColor		CPAN
  +	Term::Cap               Standard perl distribution
  +	Curses                  CPAN
  +	Term::ANSIColor         CPAN
   
   =item Mouse
   
  -    Tk				CPAN
  +	Tk                      CPAN
   
   =back
   
  -Some of these specific cases are shown below.
  +Some of these specific cases are shown as examples in other answers
  +in this section of the perlfaq.
   
   =head2 How do I print something out in color?
   
  
  
  
  1.27      +5 -5      perlfaq/perlfaq9.pod
  
  Index: perlfaq9.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq9.pod,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- perlfaq9.pod	21 Nov 2005 17:43:13 -0000	1.26
  +++ perlfaq9.pod	30 Dec 2005 15:04:07 -0000	1.27
  @@ -606,14 +606,14 @@
   name, or the domain name.
   
   	use Net::Domain qw(hostname hostfqdn hostdomain);
  -	
  +
   	my $host = hostfqdn();
   
   The C<Sys::Hostname> module, included in the standard distribution since
   perl5.6, can also get the hostname.
   
   	use Sys::Hostname;
  -	
  +
   	$host = hostname();
   
   To get the IP address, you can use the C<gethostbyname> built-in function
  @@ -622,8 +622,8 @@
   from the <Socket> module, which also comes with perl.
   
       use Socket;
  -    
  -    my $address = inet_ntoa( 
  +
  +    my $address = inet_ntoa(
       	scalar gethostbyname( $host || 'localhost' )
       	);