Skip to content

Commit

Permalink
Applied changes suggested by Jan Krynicky.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromatic committed Jul 1, 2010
1 parent 1e83008 commit 0ffa70d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
3 changes: 3 additions & 0 deletions CREDITS
Expand Up @@ -77,3 +77,6 @@ E: sartak@bestpractical.com


N: Mark A. Stratman N: Mark A. Stratman
E: mark@sporkstorms.org E: mark@sporkstorms.org

N: Jan Krynicky
E: Jenda@Krynicky.cz
34 changes: 13 additions & 21 deletions sections/implicit_ideas.pod
Expand Up @@ -47,19 +47,12 @@ other arguments:


=begin programlisting =begin programlisting


print; # prints $_ print; # prints $_ to the currently selected filehandle
say; # prints $_ with a trailing newline say; # prints $_ to the currently selected filehandle
# with a trailing newline


=end programlisting =end programlisting


=begin sidebar

If you use the three-argument form of C<print> and C<say>, where the first
argument is a filehandle to which to print, you cannot omit C<$_>; Perl will
interpret this as the two-argument form of both functions.

=end sidebar

Perl's regular expression facilities (L<regular_expressions>) can also operate Perl's regular expression facilities (L<regular_expressions>) can also operate
on C<$_>, performing matches, substitutions, and transliterations: on C<$_>, performing matches, substitutions, and transliterations:


Expand Down Expand Up @@ -126,9 +119,9 @@ list two at a time.


=end sidebar =end sidebar


If you call subroutines within code that uses C<$_> whether implicitly or If you call functions within code that uses C<$_> whether implicitly or
explicitly, they may overwrite the value of C<$_>. Similarly, if you write a explicitly, they may overwrite the value of C<$_>. Similarly, if you write a
subroutine which uses C<$_>, you may clobber a caller subroutine's use of function which uses C<$_>, you may clobber a caller function's use of
C<$_>. Perl 5.10 allows you to use C<my> to declare C<$_> as a lexical C<$_>. Perl 5.10 allows you to use C<my> to declare C<$_> as a lexical
variable, which prevents this clobbering behavior. Be wise. variable, which prevents this clobbering behavior. Be wise.


Expand All @@ -146,7 +139,7 @@ variable, which prevents this clobbering behavior. Be wise.


=end programlisting =end programlisting


In this example, if C<calculate_value()> or any other subroutine it happened to In this example, if C<calculate_value()> or any other function it happened to
call changed C<$_>, it would remain changed throughout the C<while> loop. call changed C<$_>, it would remain changed throughout the C<while> loop.
Adding a C<my> declaration prevents that behavior: Adding a C<my> declaration prevents that behavior:


Expand Down Expand Up @@ -178,9 +171,8 @@ X<default array variables>
X<variables; @_> X<variables; @_>
X<@_> X<@_>


Another default variable is available inside Perl subroutines; this is C<@_>. Perl passes arguments to functions in an array named C<@_>. Array manipulation
Perl passes arguments to subroutines in this array. Array manipulation operations (L<arrays>) performed inside functions affect this array by
operations (L<arrays>) performed inside subroutines affect this array by
default. Thus, these two snippets of code are equivalent: default. Thus, these two snippets of code are equivalent:


=begin programlisting =begin programlisting
Expand All @@ -200,17 +192,17 @@ default. Thus, these two snippets of code are equivalent:
=end programlisting =end programlisting


I<Unlike> C<$_>, Perl automatically localizes C<@_> for you when you call other I<Unlike> C<$_>, Perl automatically localizes C<@_> for you when you call other
subroutines. Array functions such as C<unshift>, C<push>, C<splice>, and functions. Array functions such as C<unshift>, C<push>, C<splice>, and
C<pop> operate on C<@_>. C<pop> operate on C<@_>.


X<variables; @ARGV> X<variables; @ARGV>
X<@ARGV> X<@ARGV>


Outside of a subroutine, the default array variable is C<@ARGV>. This array Outside of a function, the default array variable is C<@ARGV>. This array
represents all command-line arguments to the program. The same array functions represents all command-line arguments to the program. The same array functions
which use C<@_> implicitly I<within> subroutines use C<@ARGV> implicitly at the which use C<@_> implicitly I<within> functions use C<@ARGV> implicitly at the
top level of a program outside of any subroutine. You cannot use C<@_> when top level of a program outside of any function. You cannot use C<@_> when you
you mean C<@ARGV>. mean C<@ARGV>.


X<null filehandle> X<null filehandle>
X<@ARGV> X<@ARGV>
Expand Down
13 changes: 7 additions & 6 deletions sections/perldoc.pod
Expand Up @@ -3,16 +3,17 @@
Z<perldoc> Z<perldoc>


One of Perl's most useful and least appreciated features is the C<perldoc> One of Perl's most useful and least appreciated features is the C<perldoc>
utility. This program is part of every complete Perl 5 installationN<On free utility. This program is part of every complete Perl 5 installationN<You may
Unix-like systems you may need to install a package such as C<perl-doc>.>. It have to install an additional package on a free Unix-like system; on Debian and
displays the documentation of every Perl module installed on the Ubuntu this is C<perl-doc>.>. It displays the documentation of every Perl
system--whether a core module or one installed from the CPAN--as well as module installed on the system--whether a core module or one installed from the
thousands of pages of Perl's copious core documentation. CPAN--as well as thousands of pages of Perl's copious core documentation.


=begin sidebar =begin sidebar


If you prefer an online version, U<http://perldoc.perl.org/> hosts recent If you prefer an online version, U<http://perldoc.perl.org/> hosts recent
versions of the Perl documentation. versions of the Perl documentation. Windows users, both ActivePerl and
Strawberry Perl provide a link in your Start menu to the documentation.


=end sidebar =end sidebar


Expand Down

0 comments on commit 0ffa70d

Please sign in to comment.