From: Perl 5 Porters Date: Fri, 5 Jul 1996 03:56:18 +0000 (+0000) Subject: perl 5.003_01: pod/perlsub.pod X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=6d28dffb193f5fad8017f93037874bf95b65ec8f;p=p5sagit%2Fp5-mst-13.2.git perl 5.003_01: pod/perlsub.pod Typos corrected Update reference to AutoLoader/AutoSplit documentation --- diff --git a/pod/perlsub.pod b/pod/perlsub.pod index b308298..4d186d2 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -58,10 +58,10 @@ indistinguishable list. Perl does not have named formal parameters, but in practice all you do is assign to a my() list of these. Any variables you use in the function that aren't declared private are global variables. For the gory details -on creating private variables, see the sections below on L<"Private -Variables via my()"> and L. To create -protected environments for a set of functions in a separate package (and -probably a separate file), see L. +on creating private variables, see the sections below on +L<"Private Variables via my()"> and L<"Temporary Values via local()">. +To create protected environments for a set of functions in a separate +package (and probably a separate file), see L. Example: @@ -286,7 +286,7 @@ That will print out 20 and 10. You may declare "my" variables at the outer most scope of a file to totally hide any such identifiers from the outside world. This is similar -to a C's static variables at the file level. To do this with a subroutine +to C's static variables at the file level. To do this with a subroutine requires the use of a closure (anonymous function). If a block (such as an eval(), function, or C) wants to create a private subroutine that cannot be called from outside that block, it can declare a lexical @@ -342,7 +342,7 @@ See L about the BEGIN function. =head2 Temporary Values via local() B: In general, you should be using "my" instead of "local", because -it's faster and safer. Execeptions to this include the global punctuation +it's faster and safer. Exceptions to this include the global punctuation variables, filehandles and formats, and direct manipulation of the Perl symbol table itself. Format variables often use "local" though, as do other variables whose current value must be visible to called @@ -637,7 +637,7 @@ without the prototype. The interesting thing about & is that you can generate new syntax with it: - sub try (&$) { + sub try (&@) { my($try,$catch) = @_; eval { &$try }; if ($@) { @@ -764,7 +764,7 @@ should just call system() with those arguments. All you'd do is this: system($program, @_); } date(); - who('am', i'); + who('am', 'i'); ls('-l'); In fact, if you preclare the functions you want to call that way, you don't @@ -779,9 +779,10 @@ A more complete example of this is the standard Shell module, which can treat undefined subroutine calls as calls to Unix programs. Mechanisms are available for modules writers to help split the modules -up into autoloadable files. See the standard AutoLoader module described -in L, the standard SelfLoader modules in L, and -the document on adding C functions to perl code in L. +up into autoloadable files. See the standard AutoLoader module +described in L and in L, the standard +SelfLoader modules in L, and the document on adding C +functions to perl code in L. =head1 SEE ALSO