This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
msgrcv: properly downgrade the receive buffer
[perl5.git] / pod / perlsub.pod
index a761e3d..629a273 100644 (file)
@@ -224,7 +224,12 @@ X<recursion>
     &foo();            # the same
 
     &foo;              # foo() get current args, like foo(@_) !!
-    foo;               # like foo() IFF sub foo predeclared, else "foo"
+    use strict 'subs';
+    foo;                # like foo() iff sub foo predeclared, else
+                        # a compile-time error
+    no strict 'subs';
+    foo;                # like foo() iff sub foo predeclared, else
+                        # a literal string "foo"
 
 Not only does the C<&> form make the argument list optional, it also
 disables any prototype checking on arguments you do provide.  This
@@ -973,7 +978,9 @@ Perl will print
     The array has 6 elements: 0, 1, 2, undef, undef, 5
 
 The behavior of local() on non-existent members of composite
-types is subject to change in future.
+types is subject to change in future. The behavior of local()
+on array elements specified using negative indexes is particularly
+surprising, and is very likely to change.
 
 =head3 Localized deletion of elements of composite types
 X<delete> X<local, composite type element> X<local, array element> X<local, hash element>
@@ -1460,7 +1467,7 @@ corresponding built-in.
    sub myjoin ($@)        myjoin ":", $a, $b, $c
    sub mypop (\@)         mypop @array
    sub mysplice (\@$$@)           mysplice @array, 0, 2, @pushme
-   sub mykeys (\[%@])     mykeys %{$hashref}
+   sub mykeys (\[%@])     mykeys $hashref->%*
    sub myopen (*;$)       myopen HANDLE, $name
    sub mypipe (**)        mypipe READHANDLE, WRITEHANDLE
    sub mygrep (&@)        mygrep { /foo/ } $a, $b, $c
@@ -1645,7 +1652,7 @@ inlining.  If the result after optimization and constant folding
 is either a constant or a lexically-scoped scalar which has no other
 references, then it will be used in place of function calls made
 without C<&>.  Calls made using C<&> are never inlined.  (See
-F<constant.pm> for an easy way to declare most constants.)
+L<constant> for an easy way to declare most constants.)
 
 The following functions would all be inlined:
 
@@ -1947,12 +1954,13 @@ let's pretend that a function that wasn't defined should just invoke
 C<system> with those arguments.  All you'd do is:
 
     sub AUTOLOAD {
-       my $program = $AUTOLOAD;
-       $program =~ s/.*:://;
-       system($program, @_);
+        our $AUTOLOAD;              # keep 'use strict' happy
+        my $program = $AUTOLOAD;
+        $program =~ s/.*:://;
+        system($program, @_);
     }
     date();
-    who('am', 'i');
+    who();
     ls('-l');
 
 In fact, if you predeclare functions you want to call that way, you don't
@@ -1960,7 +1968,7 @@ even need parentheses:
 
     use subs qw(date who ls);
     date;
-    who "am", "i";
+    who;
     ls '-l';
 
 A more complete example of this is the Shell module on CPAN, which