X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlref.pod;h=427fee7ab797dcc81cbf887dfb38e12bd1e2501f;hb=f26f4a2f8b63c72a33468ddeeb9d0337f0892af6;hp=07b2f8272fa38c075538a9ff6cec434d19a17b39;hpb=b5c19bd7c15bd02a18c3c2b80b6f602827ecdbcc;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlref.pod b/pod/perlref.pod index 07b2f82..427fee7 100644 --- a/pod/perlref.pod +++ b/pod/perlref.pod @@ -591,13 +591,13 @@ get to capture each time you execute the 'sub' operator. If you are accustomed to using nested subroutines in other programming languages with their own private variables, you'll have to work at it a bit in Perl. The intuitive coding of this type of thing incurs mysterious warnings about -``will not stay shared''. For example, this won't work: +"will not stay shared". For example, this won't work: sub outer { my $x = $_[0] + 35; sub inner { return $x * 19 } # WRONG return $x + inner(); - } + } A work-around is the following: @@ -605,7 +605,7 @@ A work-around is the following: my $x = $_[0] + 35; local *inner = sub { return $x * 19 }; return $x + inner(); - } + } Now inner() can only be called from within outer(), because of the temporary assignments of the closure (anonymous subroutine). But when