X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pod%2Fperlsub.pod;h=74d0b1ac26fed091d13a05a0fbfd40c241606d29;hb=71c4dbc37189d1d137ba8e40103273462dd96945;hp=a04dfc95c4678dbf1f28e6649e76e79a28060b87;hpb=b708784ed29bddb36a466db5f726fe7b7635e19b;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pod/perlsub.pod b/pod/perlsub.pod index a04dfc9..74d0b1a 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -453,11 +453,10 @@ each time the gimme_another() function is called: Also, since C<$x> is lexical, it can't be reached or modified by any Perl code outside. -Be aware that assignment to C variables (as in C) -are executed every time; to initialize (or re-initialize) an undefined -state scalar, you can use, for example, the defined-or assignment : - - state $x //= initial_value(); +When combined with variable declaration, simple scalar assignment to C +variables (as in C) is executed only the first time. When such +statements are evaluated subsequent times, the assignment is ignored. The +behavior of this sort of assignment to non-scalar variables is undefined. =head3 Persistent variables with closures @@ -1035,7 +1034,7 @@ corresponding built-in. sub myreverse (@) myreverse $a, $b, $c sub myjoin ($@) myjoin ":", $a, $b, $c sub mypop (\@) mypop @array - sub mysplice (\@$$@) mysplice @array, @array, 0, @pushme + sub mysplice (\@$$@) mysplice @array, 0, 2, @pushme sub mykeys (\%) mykeys %{$hashref} sub myopen (*;$) myopen HANDLE, $name sub mypipe (**) mypipe READHANDLE, WRITEHANDLE @@ -1302,10 +1301,9 @@ that understands regular expressions. sub glob { my $pat = shift; my @got; - local *D; - if (opendir D, '.') { - @got = grep /$pat/, readdir D; - closedir D; + if (opendir my $d, '.') { + @got = grep /$pat/, readdir $d; + closedir $d; } return @got; }