In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/42993a5c4912d5546ce7c95cae4169e1e613106c?hp=da36747dd51a927ea304a8bfab181c8e794b1e17>
- Log ----------------------------------------------------------------- commit 42993a5c4912d5546ce7c95cae4169e1e613106c Author: Father Chrysostomos <[email protected]> Date: Sat Feb 19 17:40:37 2011 -0800 Minor perlfaq9 tweaks M pod/perlfaq9.pod commit c315a7016f1af4812d86126359e5bc25697ef208 Author: Father Chrysostomos <[email protected]> Date: Sat Feb 19 17:30:45 2011 -0800 Minor perlfaq8 tweaks M pod/perlfaq8.pod commit b056a7aa384a2137a7ce032755b4cf7e334b6d61 Author: Father Chrysostomos <[email protected]> Date: Sat Feb 19 11:50:34 2011 -0800 perlfaq7: simple hash keys are always quoted M pod/perlfaq7.pod commit 4c7f4b6b5392d642007d0850a1b9fed1b2a678b6 Author: Father Chrysostomos <[email protected]> Date: Sat Feb 19 11:49:31 2011 -0800 Minor perlfaq7 tweaks M pod/perlfaq7.pod ----------------------------------------------------------------------- Summary of changes: pod/perlfaq7.pod | 25 +++++++++++++------------ pod/perlfaq8.pod | 16 ++++++++-------- pod/perlfaq9.pod | 8 ++++---- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/pod/perlfaq7.pod b/pod/perlfaq7.pod index 5d7a1e8..fcf270d 100644 --- a/pod/perlfaq7.pod +++ b/pod/perlfaq7.pod @@ -29,7 +29,8 @@ They are type specifiers, as detailed in L<perldata>: * for all types of that symbol name. In version 4 you used them like pointers, but in modern perls you can just use references. -There are couple of other symbols that you're likely to encounter that aren't +There are a couple of other symbols that +you're likely to encounter that aren't really type specifiers: <> are used for inputting a record from a filehandle. @@ -48,8 +49,8 @@ I<not> use the brackets. These are correct: C<eof(FH)>, C<seek(FH, 0, Normally, a bareword doesn't need to be quoted, but in most cases probably should be (and must be under C<use strict>). But a hash key -consisting of a simple word (that isn't the name of a defined -subroutine) and the left-hand operand to the C<< => >> operator both +consisting of a simple word and the left-hand +operand to the C<< => >> operator both count as though they were quoted: This is like this @@ -332,7 +333,7 @@ package: sub next_id { ++$id } } -This is discussed in more detail in L<perlsub>, see the entry on +This is discussed in more detail in L<perlsub>; see the entry on I<Persistent Private Variables>. =head2 What is variable suicide and how can I prevent it? @@ -553,7 +554,7 @@ For instance: Notice how at no point does the value "private" get printed. That's because $var only has that value within the block of the lexical() -function, and it is hidden from called subroutine. +function, and it is hidden from the called subroutine. In summary, local() doesn't make what you think of as private, local variables. It gives a global variable a temporary value. my() is @@ -796,7 +797,7 @@ out L<perltoot> for details about any of the above cases. You may also use C<print ref($object)> to find out the class C<$object> was blessed into. -Another possible reason for problems is because you've used the +Another possible reason for problems is that you've used the indirect object syntax (eg, C<find Guru "Samy">) on a class name before Perl has seen that such a package exists. It's wisest to make sure your packages are all defined before you start using them, which @@ -942,8 +943,8 @@ altogether. Global variables are bad because they can easily collide accidentally and in general make for non-scalable and confusing code. Symbolic references are forbidden under the C<use strict> pragma. -They are not true references and consequently are not reference counted -or garbage collected. +They are not true references and consequently are not reference-counted +or garbage-collected. The other reason why using a variable to hold the name of another variable is a bad idea is that the question often stems from a lack of @@ -980,7 +981,7 @@ make it less confusing, like bracketed percent symbols, etc. $str =~ s/%(\w+)%/$USER_VARS{$1}/g; # no /e here at all Another reason that folks sometimes think they want a variable to -contain the name of a variable is because they don't know how to build +contain the name of a variable is that they don't know how to build proper data structures using hashes. For example, let's say they wanted two hashes in their program: %fred and %barney, and that they wanted to use another scalar variable to refer to those by name. @@ -1001,7 +1002,7 @@ And just use a multilevel hash to start with. The only times that you absolutely I<must> use symbolic references are when you really must refer to the symbol table. This may be because it's -something that can't take a real reference to, such as a format name. +something that one can't take a real reference to, such as a format name. Doing so may also be important for method calls, since these always go through the symbol table for resolution. @@ -1017,8 +1018,8 @@ can play around with the symbol table. For example: All those functions (red(), blue(), green(), etc.) appear to be separate, but the real code in the closure actually was compiled only once. -So, sometimes you might want to use symbolic references to directly -manipulate the symbol table. This doesn't matter for formats, handles, and +So, sometimes you might want to use symbolic references to manipulate +the symbol table directly. This doesn't matter for formats, handles, and subroutines, because they are always global--you can't use my() on them. For scalars, arrays, and hashes, though--and usually for subroutines-- you probably only want to use hard references. diff --git a/pod/perlfaq8.pod b/pod/perlfaq8.pod index 0e9fcc5..adc1d49 100644 --- a/pod/perlfaq8.pod +++ b/pod/perlfaq8.pod @@ -289,7 +289,7 @@ L<perlfunc/"sysopen"> for more on this approach. Some devices will be expecting a "\r" at the end of each line rather than a "\n". In some ports of perl, "\r" and "\n" are different from -their usual (Unix) ASCII values of "\012" and "\015". You may have to +their usual (Unix) ASCII values of "\015" and "\012". You may have to give the numeric values you want directly, using octal ("\015"), hex ("0x0D"), or as a control-character specification ("\cM"). @@ -524,7 +524,7 @@ L<perlfunc/syscall>. =head2 How can I do an atexit() or setjmp()/longjmp()? (Exception handling) You can use the C<END> block to simulate C<atexit()>. Each package's -C<END> block is called when the program or thread ends See L<perlmod> +C<END> block is called when the program or thread ends. See the L<perlmod> manpage for more details about C<END> blocks. For example, you can use this to make sure your filter program managed @@ -860,7 +860,7 @@ list. Further examples of this can be found in L<perlipc/"Safe Pipe Opens">. Note that if you're using Windows, no solution to this vexing issue is -even possible. Even if Perl were to emulate C<fork()>, you'd still be +even possible. Even though Perl emulates C<fork()>, you'll still be stuck, because Windows does not have an argc/argv-style API. =head2 Why can't my script read from STDIN after I gave it EOF (^D on Unix, ^Z on MS-DOS)? @@ -1302,11 +1302,11 @@ include path (@INC) at runtime?> for details on how to run your newly installed modules. There is one caveat with INSTALL_BASE, though, since it acts -differently than the PREFIX and LIB settings that older versions of +differently from the PREFIX and LIB settings that older versions of C<ExtUtils::MakeMaker> advocated. INSTALL_BASE does not support installing modules for multiple versions of Perl or different -architectures under the same directory. You should consider if you -really want that , and if you do, use the older PREFIX and LIB +architectures under the same directory. You should consider whether you +really want that and, if you do, use the older PREFIX and LIB settings. See the C<ExtUtils::Makemaker> documentation for more details. =head2 How do I add the directory my program lives in to the module/library search path? @@ -1391,8 +1391,8 @@ environment variables, run-time switches, and in-code statements: =back -The last is particularly useful because it knows about machine -dependent architectures. The C<lib.pm> pragmatic module was first +The last is particularly useful because it knows about machine-dependent +architectures. The C<lib.pm> pragmatic module was first included with the 5.002 release of Perl. =head2 What is socket.ph and where do I get it? diff --git a/pod/perlfaq9.pod b/pod/perlfaq9.pod index 41de7e8..d00d918 100644 --- a/pod/perlfaq9.pod +++ b/pod/perlfaq9.pod @@ -36,7 +36,7 @@ job to create an accurate HTTP response based on it). So "\n" written in text mode is technically correct, and recommended. NPH scripts are more tricky: they must put out a complete and accurate set of HTTP transaction response headers; the HTTP specification calls for records -to be terminated with carriage-return and line-feed, i.e ASCII \015\012 +to be terminated with carriage-return and line-feed; i.e., ASCII \015\012 written in binary mode. Using C<CGI.pm> gives excellent platform independence, including EBCDIC @@ -56,7 +56,7 @@ guide on Perlmonks: =head2 How can I get better error messages from a CGI program? Use the C<CGI::Carp> module. It replaces C<warn> and C<die>, plus the -normal C<Carp> modules C<carp>, C<croak>, and C<confess> functions with +normal C<Carp> module's C<carp>, C<croak>, and C<confess> functions with more verbose and safer versions. It still sends them to the normal server error log. @@ -96,7 +96,7 @@ attempts to do a little simple formatting of the resulting plain text. Many folks attempt a simple-minded regular expression approach, like C<< s/<.*?>//g >>, but that fails in many cases because the tags may continue over line breaks, they may contain quoted angle-brackets, -or HTML comment may be present. Plus, folks forget to convert +or HTML comments may be present. Plus, folks forget to convert entities--like C<<> for example. Here's one "simple-minded" approach, that works for most files: @@ -147,7 +147,7 @@ You can use C<URI::Find> to extract URLs from an arbitrary text document. Less complete solutions involving regular expressions can save you a lot of processing time if you know that the input is simple. One solution from Tom Christiansen runs 100 times faster than most -module based approaches but only extracts URLs from anchors where the first +module-based approaches but only extracts URLs from anchors where the first attribute is HREF and there are no other attributes. #!/usr/bin/perl -n00 -- Perl5 Master Repository
