Skip to content

Commit f31e6c6

Browse files
rjbskhwilliamson
authored andcommitted
perlsub: correct pre-postderef language about "starts with"
It's no longer correct that `\%` means "must start with %", because it could instead end with ->%* -- and in fact one of the examples already showed that! I also replaced the list of declarators with "my and others", to keep it more futureproof. "state", for example, had been omitted.
1 parent 62539e1 commit f31e6c6

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

pod/perlsub.pod

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,10 +1523,21 @@ corresponding built-in.
15231523
sub mytime () mytime
15241524

15251525
Any backslashed prototype character represents an actual argument
1526-
that must start with that character (optionally preceded by C<my>,
1527-
C<our> or C<local>), with the exception of C<$>, which will
1528-
accept any scalar lvalue expression, such as C<$foo = 7> or
1529-
C<< my_function()->[0] >>. The value passed as part of C<@_> will be a
1526+
really using that character for type, with the exception of C<$>, which will
1527+
accept any scalar lvalue expression, such as C<$foo = 7> or C<<
1528+
my_function()->[0] >>. "Using that character for type" means that the
1529+
expression I<begins> with the sigil (optionally preceded by a declarator like
1530+
C<my>) or I<ends> with the sigil's postfix dereference form. Any of these, for
1531+
example, satisfies C<\%>:
1532+
1533+
%hash
1534+
%$hashref
1535+
my %hash
1536+
$hashref->%*
1537+
%{ expr }
1538+
(expr)->*%
1539+
1540+
The value passed as part of C<@_> will be a
15301541
reference to the actual argument given in the subroutine call,
15311542
obtained by applying C<\> to that argument.
15321543

0 commit comments

Comments
 (0)